INSERT multiple rows using one button
Posted: Mon Apr 04, 2016 5:59 pm
i have a checks in form to check people in to an office it is currently a basic insert form but i want to be able to just tick the relevant check boxes for who has attended then confirm all at once rather than doing them individually by seperate buttons
the form looks like this
Code: Select all
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO sd_attendance (attendance_date, attendance_cust_id, attendance) VALUES (%s, %s, %s)",
GetSQLValueString($_POST['attendance_date'], "date"),
GetSQLValueString($_POST['attendance_cust_id'], "int"),
GetSQLValueString(isset($_POST['attendance']) ? "true" : "", "defined","1","0"));
mysql_select_db($database_sdma, $sdma);
$Result1 = mysql_query($insertSQL, $sdma) or die(mysql_error());
$insertGoTo = "register-list.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}Code: Select all
<form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
<input type="checkbox" name="attendance" value="" />
<input type="hidden" name="attendance_date" value="<?php echo date("Y-m-d");?>" />
<input type="hidden" name="attendance_cust_id" value="<?php echo $row_rsLesson['custID']; ?>" />
<input type="hidden" name="MM_insert" value="form1" />
<input type="submit" value="CONFIRM" />
</form>