I have searched and searched the net for something I need. But to not much avail. I know this will require an array, but I am at a loss to get this script going. So I will describe this scenario and see if anyone has run across this routine.
I have a list of participants. The query that pulls the participants also checks to see if they have been issued the award they get for completing the project. The award flag if checked if this is the case. Now I want to be able to check as many users as needed and submit to give them their award. Now here is the tricky part. The award is not a simple flag field in the user database but a table of it's own (award_id, campaign_id). So need run an INSERT on all the newly checked rows, and DELETE on those that were checked and are now unchecked. The later is really optional as I have a simple click function next to each name to remove the award.
Here is a quick visual of the page to date:
http://www.armorama.com/modules.php?op=modload&name=Campaigns&file=leader_admin&req=list_members&id=2
Here is the code on that page:
function list_members($id) {
global $admin, $pntable, $dbconn, $ModName, $userinfo;
include ('header.php');
OpenTable();
$result = $dbconn->Execute("SELECT award_id, title FROM $pntable[campaigns] WHERE id = $id");
list($aid, $title) = $result->fields;
if(!isset($aid)) {
echo _NOAWARD;
} else {
$result2 = $dbconn->Execute("SELECT e.uid, u.uname
FROM $pntable[campaigns_enlisted] e
LEFT JOIN $pntable[users] u ON e.uid = u.uid
WHERE e.cpid = $id");
echo "<font class=\"pn-normal\"><b>$title "._ENLISTEES."</b></font><br><img src=\"images/global/blackpixel.gif\" width=\"170\" height=\"1\">"
."<br><font class=\"pn-sub\">"._AWARDRIBBONS."</font><br><br>"
."<form action=\"modules.php\" method=\"post\">"
."<input type=\"hidden\" name=\"op\" value=\"modload\">"
."<input type=\"hidden\" name=\"name\" value=\"$ModName\">"
."<input type=\"hidden\" name=\"file\" value=\"leader_admin\">"
."<input type=\"hidden\" name=\"req\" value=\"update\">"
."<table cellspacing=\"5\" cellpadding=\"5\" border=\"0\"><tr><td>award</td><td>Callsign</td></tr>";
while(list($uid, $callsign) = $result2->fields) {
$result2->MoveNext();
$result3 = $dbconn->Execute("SELECT award_id FROM $pntable[awards_holders] WHERE user_id = $uid AND award_id = $aid");
list($award) = $result3->fields;
if($award==$aid) {
$remove = " [<a href=\"modules.php?op=modload&name=$ModName&file=leader_admin&req=remove_award&uid=$uid&id=$id\">"._REMOVEAWARD."</a>]";
$checked = " CHECKED";
}
echo "<tr><td><input type=\"checkbox\" value=\"awards[$award]\" name=\"awards[$uid]\"$checked></td><td><font class=\"pn-normal\"><b>"
."<a class=\"pn-normal\" href=\"modules.php?op=modload&name=$ModName&file=index&req=UserJournal&uname=$callsign&id=$id\">$callsign</a>"
."</b>$remove</font></td></tr>";
}
}
echo "</table><p><input class=\"pn-button\" value=\"Update\" name=\"update\" type=\"submit\"></form></p>";
CloseTable();
include ('footer.php');
}
Pardon all the additional crap.
Thanks for any ideas or direction.
Jim