hi all
i want to add all students grades in one form
and then save each grade to the correct student
i make 2 differents php page first one display all student id that is already registered in my website
in this page instructor can add grade for each student id
then when click save
it will go to another php that take all student id as array
and must chick all id and put a correct mark with suitable id
this is the first php
<?php
include ('createDB.php');
mysql_query($sql,$con);
$ID=0;
$result = mysql_query("SELECT * FROM StudentsGrades");
echo "<table border='1'>";
// Execute query
while($row = mysql_fetch_array($result))
{
// print table data
echo "<tr>";
echo "<td>" . $row['student_ID'] . "</td>";
echo "<td><form action='g1.php' method='post'><input type='text' name='grade' id='".$ID."' /></td></tr>";
$ID = $ID + 1;
}
echo "<tr><td><input type='submit' value='save' /></form></td></tr>";
echo "</table>";
?>
and the second
<?php
include ('createDB.php');
//select a DB
mysql_select_db("www_app", $con);
$select1= mysql_query("SELECT * FROM StudentsGrades");
$count = mysql_num_rows($select1);
while ($row=mysql_fetch_array($select1)) {
for($i = 0; $i <= $count; $i = $i + 1)
$result[] = ($row['student_ID']);
}
//**********************************************
$doc = new DomDocument;
$grades= $_POST['grade'];
for($j = 0; $j <= $count; $j = $j + 1)
$gradesArr[] = $doc->getElementById('j');
//===============================================
foreach($gradesArr as $keyGrade => $valueGrade)
{
foreach($result as $key => $valueID)
{
if($key ==$keyGrade)
{
$sql=("UPDATE StudentsGrades SET grade ='{$valueGrade}'
WHERE student_ID ='{$valueID}'");
echo "first ".$valueGrade;
echo " ".$valueID;
}//if
echo "second " .$valueGrade;
echo " ".$valueID;
}//seconf for
echo "therd ".$valueGrade;
echo " ".$valueID;
}//first for
mysql_query($sql,$con);
mysql_close($con);
?>
please i need answer as soon as possible