我正在构建一个轻量级的学校管理系统,它直接从数据库中获取成绩,如何同时更新所有值。请帮忙
<?php
$mydb->setQuery("SELECT * FROM tblbible");
loadresult();
function loadresult(){
global $mydb;
$cur = $mydb->loadResultList();
foreach ($cur as $result) {
echo '<tr>';
echo '<td> <input type="hidden" name="studentID" value="'. $result->studentID.'" /></td>';
?>
<?php
$rowz = mysql_query("SELECT * FROM tblstudent where studentID = '$result->studentID' ")or die(mysql_error());
$detailz = mysql_fetch_array($rowz);
echo '<td>'.$detailz['name'].' '.$detailz['initial'].' '.$detailz['lastname'].'</td>';
?>
<?php
echo '<td> <select name="studentID[]" class="form-control" required>
<option>Select Grade</option>
<option value="4">4</option>
<option value="3">3</option>
<option value="2">2</option>
<option value="1">1</option>
</select></td>';
echo '<td> <select name="studentID[]" class="form-control" required>
<option>Select Grade</option>
<option value="4">4</option>
<option value="3">3</option>
<option value="2">2</option>
<option value="1">1</option>
</select></td>';
echo '<td> <select name="studentID[]" class="form-control" required>
<option>Select Grade</option>
<option value="4">4</option>
<option value="3">3</option>
<option value="2">2</option>
<option value="1">1</option>
</select></td>';
?>
<?php
echo '</tr>';
}
?>
然后是下面的插入函数:
<?php
function doInsert(){
if (isset($_POST['save'])){
if ($_POST['value1'] == "" OR $_POST['value2'] == "" OR $_POST['value3'] == "") {
$messageStats = false;
message("All fields are required!","alert alert-success alert-dismissable");
redirect('index.php?page=5');
}else{
$studentID = $_POST['studentID'];
for($i = 0; $i<10; $i++) {
foreach( ($studentID) as $key => $value ) :
$cla = new Bible();
$value1 = $_POST['value1'];
$value2 = $_POST['value2'];
$value3 = $_POST['value3'];
$cla->sing =$value1;
$cla->verses =$value2;
$cla->prayer =$value3;
$cla->update($studentID);
redirect('index.php?page=5');
message("Report generated successfully!", "info");
endforeach;
}
}
}
}
我希望通过一键式按钮添加所有这些内容。