I'm having trouble updating the data of grades in each subject I'm doing this and I can't figure the answer.
What is happening is when I press the submit button to update the grades of one subject all data of all subject will have the same value with the one I updated.
Here is my code:
<table>
<thead>
<tr>
<th width="12%">Code</th>
<th>Subject</th>
<th width="10%">Units</th>
<th width="10%">Grades</th>
<th></th>
</tr>
</thead>
<?php
echo "<form action='student_grade.php?studentID=".$std_id."' method='POST'>";
while($student=mysql_fetch_array($records_3)){
$subject = $student['subject_name'];
$units = $student['subject_units'];
$code = $student['subject_code'];
$grade = $student['grade'];
echo "<tr>";
echo "<td>".$code."</td>";
echo "<td>".$subject."</td>";
echo "<td>".$units."</td>";
echo "<td>".$grade."</td>";
echo "<td><select name='grade'>
<option value='1'> 1 </option>
<option value='1.25'> 1.25 </option>
<option value='1.5'> 1.5 </option>
<option value='1.75'> 1.75 </option>
<option value='2'> 2 </option>
<option value='2.25'> 2.25 </option>
<option value='2.75'> 2.75 </option>
<option value='3'> 3 </option>
<option value='4'> 4 </option>
<option value='5'> 5 </option>
<option value='INC'> INC </option>
<option value='DRP'> DRP </option>
<option value='' selected> - </option>
</select>
</td>";
}
?>
</table>
and here is my update query
if (isset($_POST['save'])){
$UpdateQuery = "UPDATE student_subject SET grade='$_POST[grade]' WHERE student_id='$_POST[hidden]'";
mysql_query($UpdateQuery,$con);
echo "<meta http-equiv='refresh' content='0'>";
}
GRADES UI: