Forum Moderators: coopster
if i select class 2 from drop down box in form it should show the student name of class 2
in 15 option boxes so that I should upgrade the record of those students.
$records = null;
while ($row = mysql_fetch_array($result)) {
$update_id='update_' . $row['id']; // record id
$records .= "
<tr>
<td><input type="checkbox" name=\"$update_id\" id=\"$update_id\" value=\"$update_id\"> (" . $row['id'] . ")</td>
<td>" . $row['fname'] . ' ' . $row['lname'] . "</td>
</tr>
";
}
//
if ($records) {
echo "
<form method=\"post\" action=\"update.php\">
<table>
$records
<tr><td colspan=\"2\"><input type=\"submit\" value=\"update\"></td></tr>
</table>
";
}
else { echo "<p>No records to update.</p>"; }
foreach ($_POST as $key=>$value) {
if (preg_match('/^update\_\d+$/) and is_numeric($value)) {
// update $value, record id, here
// update table set field='blah' where id=$value;
}
}