The update
query is not working.
The problem is that the value of $rs->TestAssignmentId
, $currecord
, is not passed to the if
block.
This should happen when user presses the submit button.
$sql="SELECT * FROM tbltestassignment
WHERE TeacherId=".$_SESSION["UserId"]." AND StudentId=".$_GET["StudentId"]." AND TestId=".$_GET["TestId"];
$searchRes1 = Execute($sql);
while($rs=mysql_fetch_object($searchRes1)) {
$temp = GetSingleReconrd('tbltestassignment','QuestionIds','StudentId',$rs->StudentId);
$quesIds = explode(',',$temp);
$totalQues = count($quesIds);
$currecord = $rs->TestAssignmentId;
$temp = GetSingleReconrd('tbltestassignment','AnswerIds','StudentId',$rs->StudentId);
$ansIds = explode(',',$temp);
}
//echo "<pre>".$currecord."</pre>";
if(isset($_REQUEST["epSave"])) {
$score = array_filter($_REQUEST['score']);
$sqlup = 'UPDATE tbltestassignment SET `Score` = "'.$score.'" WHERE `TestAssignmentId` = '.$currecord;
mysql_query($sqlup);
$_SESSION["_msg"] = "Marks Successfully Added..!";
$_SESSION["_msgtype"] = 1;
$a=8;
$url = "correct.php?TestId=".$a;//$_GET['TestId'];
header("location:".$url);
die();
}
<?php
for($i=0; $i<$totalQues; $i++){
?>
<tr>
<td style="text-align:center">
<input name="score[]" id="score<?php echo $i ?>" type="text" placeholder="Enter marks here">
</td>
</tr><?php } ?>