请任何人按照以下概念提供帮助。成功添加动态表格行后,我需要将数据发布到表格
下面的页面工作正常,但是当我尝试将这些数据发布到表格中时,我在 results5.php 第 11 行错误中收到错误消息:警告:为 foreach() 提供的参数无效
结果kati.php
<head>
<script>
function addRows()
{
var a_name=document.form1.a_name.value;
var a_in=document.form1.a_in.value;
var tbl = document.getElementById('t');
var lastRow = tbl.rows.length;
var iteration = lastRow;
var row = tbl.insertRow(lastRow);
var cell1 = row.insertCell(0);
var e1 = document.createElement('input');
s=lastRow+1;
e1.type = 'text';
e1.size=1;
e1.readonly="readonly";
e1.name = 'sno';
e1.value = iteration-1;
e1.id = 'txtRow' + iteration;
cell1.appendChild(e1);
//another cell
var cellRightSel = row.insertCell(1);
var sel = document.createElement('select');
sel.name = 'a_name[]';
var rs=document.forms.form2.rws.value;
var j=0;
for(j=0;j<=rs;++j)
{
sel.options[j] = new Option(document.forms.form2.elements[j].value,document.forms.form2.elements[j].name);
if(document.forms.form2.elements[j].value==a_name)
{
sel.options[j].selected=true;
}
}
cellRightSel.appendChild(sel);
var cell2 = row.insertCell(2);
var e2 = document.createElement('input');
//s=lastRow+1;
e2.type = 'text';
e2.size=4;
e2.value=a_in;
e2.name = 'a_in[]';
e2.id = 'txtRow' + iteration;
cell2.appendChild(e2);
}
function removeRows()
{
var tbl = document.getElementById('t');
var lastRow = tbl.rows.length;
if (lastRow > 3) tbl.deleteRow(lastRow - 1);
}
function sbmt()
{
frmco.action="";
frmclose.submit();
}
</script>
<script language="javascript" type="text/javascript">
function Validate()
{
if(""==document.form7.edleveid1.value)
{
alert("Select Education Level");
document.form7.edleveid1.focus();
return false;
}
if(""==document.form7.tenure.value)
{
alert("Select currently tenure student belong to");
document.form7.tenure.focus();
return false;
}
else
{
window.location="results.php";
}
}
function Validate1()
{
if(""==document.form7.classid.value)
{
alert("Select class where student joined");
document.form7.classid.focus();
return false;
}
else
{
window.location="results.php";
}
}
function Validate2()
{
if(""==document.form7.examtype.value)
{
alert("Select exam type");
document.form7.examtype.focus();
return false;
}
if(""==document.form7.subjectid.value)
{
alert("Select subject");
document.form7.subjectid.focus();
return false;
}
else
{
window.location="results.php";
}
}
</script>
<script type="text/javascript" src="accodation/jquery-ui.js"></script>
<script type="text/javascript" src="Datepicker/jquery-1.9.js"></script>
<script type="text/javascript" src="Datepicker/jquery-ui.js"></script>
<link href="Datepicker/jquery-ui.css" rel="stylesheet" type="text/css" />
<script>
$(function() {
$( "#datepicker" ).datepicker();
});
</script>
<style type="text/css">
<!--
.style1 {color: #FF0000}
-->
</style>
</head>
<link href="css/all.css" rel="stylesheet" type="text/css" />
<div id="center-column">
<div class="top-bar">
<h1>Students</h1>
<div class="breadcrumbs"><a href="#">Homepage</a> / <a href="#">Students</a></div>
</div><br />
<?php include('searchstudents.php'); ?>
<div class="table">
<form method="GET" name="form7" class="contentArea" id="form7" action="results.php">
<img src="img/bg-th-left.gif" width="8" height="7" alt="" class="left" />
<img src="img/bg-th-right.gif" width="7" height="7" alt="" class="right" />
<table class="listing" cellpadding="0" cellspacing="0" id="tb" bgcolor="#D6D6D6">
<tr>
<th class="full" colspan="8">UPLOAD STUDENT'S RESULTS</th>
</tr>
<!--Start of default menu -->
<tr>
<td class="first" width="10"><strong>EdLevel</strong></td>
<td class="first" colspan="7">
<select name="edleveid1" id="edleveid1">
<option value="">Select Educational Level.....</option>
<?php
include("connect.php.inc");
$sq11="select TEdlevelID,Name from streams where IsActive=1 and schoolID='".$_SESSION['schoolID']."' ";
$rs11=mysql_query($sq11) or die(mysql_query());
while($row11=mysql_fetch_array($rs11))
{
$TEdlevelID=$row11['TEdlevelID'];
$name=$row11['Name'];
echo("<option value=\"".$TEdlevelID." \">".$name."</option>");
}
?>
</select>
<select name="tenure" id="tenure">
<option value="">Select Current Student Tenure</option>
<option value="1">1 Yr</option>
<option value="2">2 Yrs</option>
<option value="3">3 Yrs</option>
<option value="4">4 Yrs</option>
<option value="5">5 Yrs</option>
</select>
<input type="submit" name="next1" value="Next" class="button" onclick="return Validate()" />
</td>
</tr>
<!--End of default input field selection -->
<!--start of selected details-->
<?php
if(isset($_GET['next1']))
{
$TEdlevelID1=$_GET['edleveid1'];
$tenure=$_GET['tenure'];
?>
<tr>
<td class="first" width="10"><strong>Class</strong></td>
<td class="first" colspan="7">
<select name="classid" id="classid">
<option value="">Select Class...</option>
<?php
include("connect.php.inc");
$sq11="select c.ClassID,c.Name from streams s,classes c where s.IsActive=1 and c.IsActive=1 and s.TEdlevelID=c.EdTlevel and s.TEdlevelID='$TEdlevelID1' and s.SchoolID='".$_SESSION['schoolID']."' and c.schoolID='".$_SESSION['schoolID']."'";
$rs11=mysql_query($sq11) or die(mysql_query());
while($row11=mysql_fetch_array($rs11))
{
$ClassID=$row11['ClassID'];
$name=$row11['Name'];
echo("<option value=\"".$ClassID." \">".$name."</option>");
}
?>
</select>
<input type="hidden" name="eduIDnenda" value="<?php echo($TEdlevelID1);?>"/>
<input type="hidden" name="mda" value="<?php echo($tenure);?>"/>
<input type="submit" name="next2" value="Next" class="button" onclick="return Validate1()"/><input type="submit" name="back" value="Back" class="button" />
</td>
</tr>
<?php
}
?>
<!--<--End start of selected details-->
<!--getting exam type -->
<?php
if(isset($_GET['next2']))
{
$classido=$_GET['classid'];
$edulevo=$_GET['eduIDnenda'];
$tenurep=$_GET['mda'];
?>
<tr>
<td class="first" width="10"><strong>Exam Type</strong></td>
<td class="first" colspan="7">
<select name="examtype" id="examtype">
<option value="">Select Exam Type</option>
<?php
include("connect.php.inc");
$sq11="select e.ExamID,e.Name from examtypescore e,classes s where e.IsActive=1 and s.IsActive=1 and e.ClassID=s.ClassID and s.SchoolID='".$_SESSION['schoolID']."' and e.schoolID='".$_SESSION['schoolID']."' and e.ClassID='$classido'";
$rs11=mysql_query($sq11) or die(mysql_query());
while($row11=mysql_fetch_array($rs11))
{
$ExamID=$row11['ExamID'];
$ainamtihani=$row11['Name'];
echo("<option value=\"".$ExamID." \">".$ainamtihani."</option>");
}
?>
</select>
<strong>Subject</strong>
<select name="subjectid" id="subjectid">
<option value="">Select Subject</option>
<?php
include("connect.php.inc");
$sq11="select s.SubjectName,s.SubjectID from subjects s,streams se where s.SchoolID='".$_SESSION['schoolID']."' and se.schoolID='".$_SESSION['schoolID']."' and s.TEdLevelID='$edulevo' and s.TEdLevelID=se.TEdLevelID";
$rs11=mysql_query($sq11) or die(mysql_query());
while($row11=mysql_fetch_array($rs11))
{
$SubjectID=$row11['SubjectID'];
$SubjectName=$row11['SubjectName'];
echo("<option value=\"".$SubjectID." \">".$SubjectName."</option>");
}
?>
</select>
<input type="hidden" name="classidnenda" value="<?php echo($classido);?>"/><input type="hidden" name="elimu" value="<?php echo($edulevo);?>"/><input type="hidden" name="somo" value="<?php echo($SubjectName);?>"/><input type="hidden" name="aina" value="<?php echo($ExamID);?>"/>
<input type="hidden" name="mdaa" value="<?php echo($tenurep);?>"/>
<input type="submit" name="next3" value="Start" class="button" onclick="return Validate2()"/><input type="submit" name="back" value="Back" class="button" />
</td>
</tr>
<?php
}
?>
<!--end getting exam type -->
</form>
<form method="GET" name="form1" class="contentArea" id="form1" action="results5.php">
<!-- starting input data -->
<?php
if(isset($_GET['next3']))
{
$classid=$_GET['classidnenda'];
$elimulevo=$_GET['elimu'];
$examid=$_GET['aina'];
$somo=$_GET['subjectid'];
$tenure1=$_GET['mdaa'];
//$mdakamili=RIGHT($tenure1,1);
$sq113="select Name from streams where IsActive=1 and schoolID='".$_SESSION['schoolID']."' and TEdlevelID='$elimulevo'";
$rs113=mysql_query($sq113) or die(mysql_query());
while($row113=mysql_fetch_array($rs113))
{
$a=$row113['Name'];
}
$sq1131="select Name from examtypescore where IsActive=1 and schoolID='".$_SESSION['schoolID']."' and ExamID='$examid'";
$rs1131=mysql_query($sq1131) or die(mysql_query());
while($row1131=mysql_fetch_array($rs1131))
{
$c=$row1131['Name'];
}
$sq11312="select Name from classes where IsActive=1 and schoolID='".$_SESSION['schoolID']."' and ClassID='$classid'";
$rs11312=mysql_query($sq11312) or die(mysql_query());
while($row11312=mysql_fetch_array($rs11312))
{
$b=$row11312['Name'];
}
$sq11312="select SubjectName from subjects where IsActive=1 and schoolID='".$_SESSION['schoolID']."' and SubjectID='$somo'";
$rs11312=mysql_query($sq11312) or die(mysql_query());
while($row11312=mysql_fetch_array($rs11312))
{
$d=$row11312['SubjectName'];
}
?>
<tr>
<td class="first" width="10"><strong>EdLevel</strong></td>
<td class="first" ><?php echo($a);?><input type="hidden" class="text" size="10" name="elimuyake"value="<?php echo($elimulevo);?>"/></td>
<td class="first" width="10"><strong>Class</strong></td>
<td class="first" ><?php echo($b);?> yrs:(<?php echo($tenure1); ?>)<input type="hidden" class="text" name="darasa"size="10" value="<?php echo($classid);?>" /></td>
<td class="first" width="10"><strong>ExamType</strong></td>
<td class="first" ><?php echo($c);?><input type="hidden" class="text" size="10" name="ainamtihani"value="<?php echo($examid);?>" /></td>
<td class="first" width="10"><strong>Subject</strong></td>
<td class="first" ><?php echo($d);?><input type="hidden" name="somolake" class="text" size="10" value="<?php echo($somo);?>" /></td>
</tr>
</table>
<table class="listing" cellpadding="0" cellspacing="0" id="t" bgcolor="#D6D6D6">
<td class="first" width="10">
<input type="text" name="sn" value="1" readonly="" size="1" /></td>
<td class="first" colspan="3">
<select name="a_name" id="a_name">
<option value=""></option>
<?php
include("connect.php.inc");
$sql="SELECT s.Lname, s.Mname, s.Fname, s.studentID,s.ey,s.sy, s.ClassID, RIGHT( s.ey - s.sy, 1 ) AS yrs, str.tenure, s.schoolID, cl.EdTlevel, s.IsActive, cl.ClassID
FROM students s, streams str, classes cl
GROUP BY s.StudentID
HAVING s.schoolID ='".$_SESSION['schoolID']."'
AND s.ClassID ='$classid' and s.IsActive=1 and RIGHT( s.ey - s.sy, 1 )='$tenure1'";
$resultsx=mysql_query($sql) or die(mysql_error());
while($row11=mysql_fetch_array($resultsx))
{
$studentID=$row11['studentID'];
$ClassID=$row11['ClassID'];
$yrs=$row11['yrs'];
$Fname=$row11['Fname'];
$Mname=$row11['Mname'];
$Lname=$row11['Lname'];
echo("<option value=\"".$studentID." \">".$Fname.' '.$Mname.' '.$Lname."</option>");
}
?>
</select> <strong>Marks</strong>
<input type="text" class="text" name="a_in" size="4"/></td>
</tr>
<tr>
<td class="first" colspan="4" align="right">
<input name="Submit2" type="reset" class="button" id="Submit2" value="RESET">
<input name="Submit3" type="button" class="button" id="Submit3" value="ADD ROW" onClick="addRows()">
<input name="Submit4" type="button" class="button" id="Submit4" value="DELETE ROW" onClick="removeRows()">
<input name="save" type="submit" class="button" id="save" value="SAVE">
</td>
</tr>
<?php
}
?>
</table>
</div>
</form>
<form name="form2" class="contentArea">
<?php
if(isset($_GET['next3']))
{
error_reporting (E_ALL ^ E_NOTICE);
include("connect.php.inc");
$sq11="SELECT s.Lname, s.Mname, s.Fname, s.ey,s.sy,s.studentID, s.ClassID, RIGHT( s.ey - s.sy, 1 ) AS yrs, str.tenure, s.schoolID, cl.EdTlevel, s.IsActive, cl.ClassID
FROM students s, streams str, classes cl
GROUP BY s.StudentID
HAVING s.schoolID ='".$_SESSION['schoolID']."'
AND s.ClassID ='$classid' and s.IsActive=1 and RIGHT( s.ey - s.sy, 1 )='$tenure1'";
$resultsx=mysql_query($sql) or die(mysql_error());
while($row11=mysql_fetch_array($resultsx))
{
$studentID=$row11['studentID'];
$ClassID=$row11['ClassID'];
$yrs=$row11['yrs'];
$Fname=$row11['Fname'];
$Mname=$row11['Mname'];
$Lname=$row11['Lname'];
echo("<input name='$StudentID'\" type=\"hidden\" value='$Fname $Mname $Lname'\">");
++$n;
}
?>
<input name="rws" type="hidden" id="rws" value="<?php echo($n);?>">
</form>
<?php
}
?>
</div>
results5.php
<?php
if(isset($_GET['save']))
{
error_reporting (E_ALL ^ E_NOTICE);
$somolake=$_GET['somolake'];
$darasa=$_GET['darasa'];
$elimuyake=$_GET['elimuyake'];
$ainamtihani=$_GET['ainamtihani'];
$jina=$_GET['a_name'];
include("connect.php.inc");
foreach($_GET['a_name'] as $row=>$name)
{
//$jina=mysql_real_escape_string($name);
$jina=mysql_real_escape_string($_GET['a_name'][$row]);
//$jina=mysql_real_escape_string($_GET['a_name'][$row]);
$alama=mysql_real_escape_string($_GET['a_in'][$row]);
//$alama=mysql_real_escape_string($_GET['a_in']);
$sq2="insert into results(StudentID,SubjectID,ClassID,ExamID,Marks,SchoolID,PostedBy)
value ('$jina','$somolake','$darasa','$ainamtihani','$alama','".$_SESSION['schoolID']."','".$_SESSION['userid']."')";
mysql_query($sq2) or die(mysql_error());
}
include("success.php");
}