Update Multiple Rows with one form
I have a page that is laid out as a spreadsheet style and I want people to be able to edit multiple fields in multiple rows and it to update multiple rows at once when they submit the form. Here is the code I have so far.
<?php
$athlete = new WA_MySQLi_RS("athlete",$athletics2,0);
$athlete->setQuery("SELECT * FROM athlete_registrations left join athletes on athletes.athleteID = athlete_registrations.athleteID WHERE seasonID = ?");
$athlete->bindParam("i", "".(isset($_GET['seasonID']) ?$_GET['seasonID']:"") ."", "-1"); //colname
$athlete->execute();
?>
<?php
if (isset($_POST["Submit"]) || isset($_POST["Submit_x"])) {
$UpdateQuery = new WA_MySQLi_Query($athletics2);
$UpdateQuery->Action = "update";
$UpdateQuery->Table = "athlete_registrations";
$UpdateQuery->bindColumn("level4", "s", "".((isset($_POST["level4"]))?implode(",",$_POST["level4"]):"") ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("physical_date", "t", "".((isset($_POST["physical_date"]))?implode(",",$_POST["physical_date"]):"") ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("concussion_course2", "t", "".((isset($_POST["concussion_course2"]))?implode(",",$_POST["concussion_course2"]):"") ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("academic", "s", "".((isset($_POST["academic"]))?implode(",",$_POST["academic"]):"") ."", "WA_DEFAULT");
$UpdateQuery->bindColumn("other_medical_info", "s", "".((isset($_POST["other_medical_info"]))?implode(",",$_POST["other_medical_info"]):"") ."", "WA_DEFAULT");
$UpdateQuery->addFilter("registrationID", "=", "i", "".($athlete->getColumnVal("registrationID")) ."");
$UpdateQuery->execute();
$UpdateGoTo = "edit_office_fields.php?seasonID=".$season->getColumnVal("seasonID") ."";
if (function_exists("rel2abs")) $UpdateGoTo = $UpdateGoTo?rel2abs($UpdateGoTo,dirname(__FILE__)):"";
$UpdateQuery->redirect($UpdateGoTo);
}
?>
I have tried to incorporate loops such as these and no luck:
{
foreach( $athlete as $key => $value) {
// end loop
}
I appreciate any help you can provide. Thanks