I have a list of college courses on a page. Click on a course and you go to the course page where it listed a number of Sessions (Classes) each having its own row where I need each session (row) to have a checkbox. The checkbox is a status to show if the session has been completed.
echo "<form action='".$_server['php_self']."' method='post'>";
if($TLstatus=='1'){
echo" <td width='10%' align='center'><input type=\"checkbox\" name=\"status[]\" value=\"checked\"></td>";
}else{
echo" <td width='10%' align='center'><input type=\"checkbox\" name=\"status[]\"></td>";
}
I then have:
echo "<input type='hidden' name='Session_ID' value='$Session_ID'>\n";
echo "<td colspan=\"7\" align=\"center\"><input type=\"Submit\" name=\"Update\" value=\"Update\"></td>";
In the beginning I test to see if the form was posted:
if(isset($_POST["Update"]) && ""!=$_POST["Update"]) {
$Session_ID = $_POST['Session_ID'];
foreach($_POST['status'] as $value){
$setstatus = $db->sql_query("UPDATE ".$prefix."_tl_session SET status =$value WHERE Session_ID = '$Session_ID'");
}
}
Not working yet.
Am I in the ballpark or have I missed something?
I have status as datatype set('0', '1')