close ad
Help us test the new Databridge BETA with MySQLi support
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Update Multiple Rows with one form

Thread began 2/07/2018 9:26 am by anonymous | Last modified 3/20/2018 12:48 pm by anonymous | 595 views | 63 replies

anonymous

Here is the code. Thanks for checking this out.

<?php require_once('../../Connections/athletics2.php'); ?>
<?php require_once('../../webassist/mysqli/authentication.php'); ?>
<?php require_once('../../webassist/mysqli/rsobj.php'); ?>
<?php require_once('../../webassist/mysqli/queryobj.php'); ?>
<?php
if ("" == "") {
$RestrictAccess = new WA_MySQLi_Auth();
$RestrictAccess->Action = "restrict";
$RestrictAccess->Name = "admins";
$RestricAccessRedirect = "error.php";
if (function_exists("rel2abs")) $RestricAccessRedirect = $RestricAccessRedirect?rel2abs($RestricAccessRedirect,dirname(__FILE__)):"";
$RestrictAccess->FailRedirect = $RestricAccessRedirect;
$RestrictAccess->execute();
}?>
<?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
$season = new WA_MySQLi_RS("season",$athletics2,1);
$season->setQuery("SELECT * FROM season WHERE seasonID = ?");
$season->bindParam("i", "".(isset($_GET['seasonID'])?$_GET['seasonID']:"") ."", "-1"); //colname
$season->execute();
?>
<?php
if (isset($_POST["submit"]) || isset($_POST["submit_x"])) {
$MultipleUpdateConnection = $athletics2;
$MultipleUpdateTable = "athlete_registrations";
$MultipleUpdateRedirect = "edit_office_fields.php?seasonID=".($athlete->getColumnVal("seasonID")) ."";
$MultipleUpdateIndexColumn = "registrationID";
$MultipleUpdateIndexColumnType = "d";
$MultipleUpdateIdentifier = "WADA_RepeatID_registrationID";
$MultipleUpdateCount = 1;
while (isset($_POST[$MultipleUpdateIdentifier.'_'.$MultipleUpdateCount])) {
$UpdateQuery = new WA_MySQLi_Query($MultipleUpdateConnection);
$UpdateQuery->Action = "update";
$UpdateQuery->Table = $MultipleUpdateTable;
$UpdateQuery->bindColumn("level4", "s", "".((isset($_POST["level4"."_".$MultipleUpdateCount]))?$_POST["level4"."_".$MultipleUpdateCount]:"") ."", "WA_IGNORE");
$UpdateQuery->bindColumn("physical_date", "t", "".((isset($_POST["physical_date"."_".$MultipleUpdateCount]))?$_POST["physical_date"."_".$MultipleUpdateCount]:"") ."", "WA_IGNORE");
$UpdateQuery->bindColumn("concussion_course2", "t", "".((isset($_POST["concussion_course2"."_".$MultipleUpdateCount]))?$_POST["concussion_course2"."_".$MultipleUpdateCount]:"") ."", "WA_IGNORE");
$UpdateQuery->bindColumn("other_medical_info", "s", "".((isset($_POST["other_medical_info"."_".$MultipleUpdateCount]))?$_POST["other_medical_info"."_".$MultipleUpdateCount]:"") ."", "WA_IGNORE");
$UpdateQuery->addFilter($MultipleUpdateIndexColumn, "=", $MultipleUpdateIndexColumnType, $_POST[$MultipleUpdateIdentifier.'_'.$MultipleUpdateCount]);
$UpdateQuery->execute();
$MultipleUpdateCount++;
}
if ($MultipleUpdateRedirect) {
if (function_exists("rel2abs")) $MultipleUpdateRedirect = rel2abs($MultipleUpdateRedirect,dirname(__FILE__));
header("location: " . $MultipleUpdateRedirect);
}
}
?>
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js">
</script>
<script>
$(function() {
$( "#datepicker" ).datepicker({
numberOfMonths: 3,
showButtonPanel: true
});
});
function MM_validateForm() { //v4.0
if (document.getElementById){
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
} }
</script>
<script>
$(function() {
$( "#datepicker2" ).datepicker({
numberOfMonths: 3,
showButtonPanel: true
});
});
function MM_validateForm() { //v4.0
if (document.getElementById){
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
} if (errors) alert('The following error(s) occurred:\n'+errors);
document.MM_returnValue = (errors == '');
} }
</script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript" src="../jquery.timepicker.js"></script>
<link rel="stylesheet" type="text/css" href="../jquery.timepicker.css" />
<script type="text/javascript" src="../lib/bootstrap-datepicker.js"></script>
<link rel="stylesheet" type="text/css" href="../lib/bootstrap-datepicker.css" />
<script type="text/javascript" src="../lib/site.js"></script>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>CRLS Athletic Registration System</title>
<link href="../text_athletics_admin.css" rel="stylesheet" type="text/css">
<style type="text/css">
td img {margin: 0;}
table.sortable th:not(.sorttable_sorted):not(.sorttable_sorted_reverse):not(.sorttable_nosort):after {
content: " \25B4\25BE"
}
table.sortable tbody tr:nth-child(2n) td {
background: #cccccc;
}
table.sortable tbody tr:nth-child(2n+1) td {
background: #ccfffff;
}
</style>
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="https://cdn.datatables.net/1.10.8/js/jquery.dataTables.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.8/css/jquery.dataTables.min.css" />

<script type="text/javascript" class="init">
$(document).ready(function() {
$('#example').DataTable();
} );
</script>

<style type="text/css">
body {
background-color: #e8e5de;
}
</style>

</head>

<body>
<div class="container">
<div class="side">
<div class="header">
<h2>CRLS Athletic Registration System</h2>

</div>
<h3><?php echo($season->getColumnVal("season")); ?> Athletes</h3> <form method="post">
<table height="300px" width="100%" border="0" cellspacing="2" cellpadding="8">
<tr>
<td height="10" align="center" valign="middle" bgcolor="#CCCCCC"><a href="manage-sports.php">Manage Sports</a> | <a href="manage_positions.php">Manage Positions</a> | <a href="manage_seasons.php">Manage Seasons</a> | <a href="manage_coaches.php">Manage Coaches</a> | <a href="manage_athletes.php">Manage Athletes</a> | <a href="manage_policies.php">Manage Policies </a> | <a href="change_password.php">Change Your Password</a> | <a href="manage_admin_accounts.php">Manage Admin Accounts</a> | <a href="reports.php">Reports</a></td>
</tr>
<tr>
<td height="10" valign="top" bgcolor="#426ea0"><strong><font color="#FFFFFF">Enter the Athlete Info Below
<input type="submit" name="submit" id="submit" value="Submit">
</font></strong></td>
</tr>
<tr>
<td valign="top" align="center">

<table width="100%" border="0" cellspacing="3" id="example" cellpadding="5" class="display">
<thead>
<tr>
<th height="39" valign="top">First Name</th>
<th valign="top">Last Name</th>
<th valign="top">Student ID#</th>
<th valign="top">Level</th>
<th valign="top">Physical Date</th>
<th valign="top">Concusion Course</th>
<th valign="top">Academic</th>
<th valign="top">Other Medical Info </th>
</tr>
</thead>
<tbody>
<?php
$wa_repeatfor = -1; // Repeat Selection 1
if (!isset($wa_repeatcount)) $wa_repeatcount = 0;
while (!$athlete->atEnd() && $wa_repeatfor != 0) {
$wa_repeatfor--;
$wa_repeatcount++;
if (!$athlete->atEnd()) {
?>
<tr>
<td valign="top"><?php echo($athlete->getColumnVal("student_fname")); ?></td>
<td valign="top"><?php echo($athlete->getColumnVal("student_lname")); ?></td>
<td valign="top"><?php echo($athlete->getColumnVal("studentID")); ?></td>
<td valign="top"><label for="level4"></label>
<select name="level4_<?php echo($wa_repeatcount); ?>" id="level4_<?php echo($wa_repeatcount); ?>">
<option value="" <?php if (!(strcmp("", ($athlete->getColumnVal("level4"))))) {echo "selected=\"selected\"";} ?>>Select One</option>
<option value="Varsity" <?php if (!(strcmp("Varsity", ($athlete->getColumnVal("level4"))))) {echo "selected=\"selected\"";} ?>>Varsity</option>
<option value="JV" <?php if (!(strcmp("JV", ($athlete->getColumnVal("level4"))))) {echo "selected=\"selected\"";} ?>>JV</option>
<option value="Freshman" <?php if (!(strcmp("Freshman", ($athlete->getColumnVal("level4"))))) {echo "selected=\"selected\"";} ?>>Freshman</option>
</select></td>
<td valign="top"><label for="physical_date"></label>
<input type="hidden" name="WADA_RepeatID_registrationID_<?php echo($wa_repeatcount); ?>" id="WADA_RepeatID_registrationID_<?php echo($wa_repeatcount); ?>" value="<?php echo($athlete->getColumnVal("registrationID")); ?>" />
<input name="physical_date_<?php echo($wa_repeatcount); ?>" type="text" id="physical_date_<?php echo($wa_repeatcount); ?>" value="<?php echo(date("m/d/Y", strtotime($athlete->getColumnVal("physical_date")))); ?>">
<input name="registrationID_<?php echo($wa_repeatcount); ?>" type="hidden" id="registrationID_<?php echo($wa_repeatcount); ?>" value="<?php echo($athlete->getColumnVal("registrationID")); ?>"></td>
<td valign="top"><label for="concussion_course2"></label>
<input name="concussion_course2_<?php echo($wa_repeatcount); ?>" type="text" id="concussion_course2_<?php echo($wa_repeatcount); ?>" value="<?php echo(date("m/d/Y", strtotime($athlete->getColumnVal("concussion_course2")))); ?>"></td>
<td valign="top"><label for="academic"></label>
<?php echo($athlete->getColumnVal("academic")); ?></td>
<td valign="top"><label for="other_medical_info"></label>
<textarea name="other_medical_info_<?php echo($wa_repeatcount); ?>" id="other_medical_info_<?php echo($wa_repeatcount); ?>" cols="30" rows="3"><?php echo($athlete->getColumnVal("other_medical_info")); ?></textarea></td>
</tr>
<?php
$athlete->moveNext(); // Repeat Alternate 1
} else {
?>
<?php
} // End Repeat Alternate 1
?>
<?php
}
if (!isset($wa_startindex)) $athlete->moveFirst(); // End Repeat Selection 1
?>
</tbody>
</table>

</td>
</tr>
</table></form>
<div class="header"><p align="center"><font color="#FFFFFF">Cambridge Rindge & Latin School | <a href="http://crls.cpsd.us" target="_blank"><font color="#FFFFFF">crls.cpsd.us</font></a> | 617.349.6690</font></p></div>
</div>
</div>
</body>
</html>

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...