hi there, i need similar help...
i am trying to generate a table of users with checkboxes to be able to approve or not...once the c/boxes are checked and sent the db is updated...trouble is i am having is with separating the values in the array so that the form updates the corret user...
code for update form...
<form action="new_approve.php" method="post">
<?php
$sqlquery = "SELECT * FROM users WHERE active='0'";
$result = mysql_query($sqlquery,$connection);
$number = mysql_numrows($result);
$i = 0;
if ($number < 1) {
print "<tr><td colspan=\"8\">There are no new users to approve!</td></tr>";
}
else {
while ($number > $i) {
$thisName = mysql_result($result,$i,"first_name");
$thisLast = mysql_result($result,$i,"second_name");
$thisUser = mysql_result($result,$i,"user_name");
$thisEmail = mysql_result($result,$i,"email");
$thisActive = mysql_result($result,$i,"active");
$thisAdmin = mysql_result($result,$i,"admin");
$thisID = mysql_result($result,$i,"ID");
print "
<TR>
<TD>$thisName</TD>
<TD>$thisLast</TD>
<TD>$thisUser</TD>
<td>$thisEmail</td>
<td><input type=\"checkbox\" name=\"del[]\" value=\"$thisID\"></td>
<td>$thisAdmin</td>
<td>$thisID</td>
</TR>";
$i++;
}
}
code for new_approve
$sql="UPDATE users SET active='1' WHERE ID='$thisID'";
do {
mysql_query($sql,$connection);
}
while($x = each($del));
#{
#echo "$x[0] => $x[1]<BR>";
if (!mysql_query($sql,$connection)) {
echo "sorry Could not approve users";
}
else {
echo "Users Approved!<br>Back to <a href=\"admin.php\">Main Admin Page</a>";
}
i am v.new to php so would appreciate any help...!
mamu