I am trying to bulk update entries in a table using one form. I have seen other examples of this but I cannot seem to get them to work. I do not get any errors when I submit the form, but it will not update my db. I have experimented with a variety of methods. All I want it to be able to use a checkbox to select the entries that are approved, and then submit it to the db. Any advice is appreciated.
<form action="early_reg.php" method="post">
<table align="left">
<tr>
<td align="left">Early Registration</td>
</tr>
</table>
<br />
<br />
<table border='1' align='left' bordercolor='#000000' cellpadding='0' cellspacing='0'>
<?php
//QUERY ENTRY
$sql = ('SELECT * FROM S7preregistration order by pkPreregID ASC');
$result = mysql_query($sql);
$num_rows = mysql_num_rows($result);
// ENTRY EXISTS
if (!($num_rows == 0)) {
$myrow = mysql_fetch_array($result);
do {
printf ('<tr>');
echo "<td><input type='checkbox' name='approved[]' value='yes' /></td>";
printf ('<td align="left">%s</td>', $myrow['teamName']);
printf ('<td align="left">%s %s</td>', $myrow['firstName'], $myrow['lastName']);
printf ('<td align="left">%s</td>', $myrow['emailAddress']);
printf ('<td align="left">%s</td>', $myrow['phone']);
printf ('<td align="left">%s</td>', $myrow['description']);
printf ('<td align="left">%s</td>
</tr>', $myrow['signupDate']);
}
while ($myrow = mysql_fetch_array($result));
}
echo "<tr>
<td colspan='7' align='left'><input type='submit' name='update' value='UPDATE' /></td>
</tr>";
//SUBMIT THE INFO
if(isset($_POST['update'])){
foreach($_POST['approved'] as $approved){
mysql_query("UPDATE S7preregistration SET approved='$approved' WHERE pkPreregID='$pkPreregID'");
}
}
?>
</table>
</form>
0 comments:
Post a Comment