for ($key=0; $key < count($_POST['marks']); $key++) {
$from_marks = $_POST['from'][$key];
$get_marks = $_POST['marks'][$key];
//echo $from_marks." ";
if($get_marks > $from_marks){
// header("location: ../../pages/marks.php?over=err");
// break;
echo "Cant add more marks <br/>";
}
else{
echo $get_marks."<br/>";
$update_marks_query = $db->prepare(
"UPDATE sc_marks SET get_marks='"
.$get_marks
."' WHERE _sid='$sc_foreign_id' AND exam_type='$select_exam_type' ");
$update_marks_query -> execute();
}
}
The issue is occurred when I execute the code, I got the last fetched value in each rows of the table.
Data result after update:
<?php
include "./connection/config.php";
if(isset($_POST['btn_update_marks'])){
$sc_foreign_id = $_POST['sc_foreign_id'];
$select_exam_type = $_POST['select_exam_type'];
for($key=0; $key<count($_POST['marks']); $key++){
$from_marks = $_POST['from'][$key];
$get_marks = $_POST['marks'][$key];
echo $from_marks." ";
if($get_marks > $from_marks){
// header("location: ../../pages/marks.php?over=err");
// break;
echo "Marks Vadhu Chhe <br/>";
}
else{
echo $get_marks."<br/>";
$update_marks_query = $db->query("UPDATE sc_marks SET get_marks='".$get_marks."' WHERE _sid='$sc_foreign_id' AND exam_type='$select_exam_type' ");
}
// else{
// $update_marks_query = $db->prepare("UPDATE sc_marks SET get_marks='$get_marks' WHERE _sid='$sc_foreign_id' ");
// $update_done = $update_marks_query -> execute();
// }
}
// if($update_done){
// echo "Successfully Updated";
// header("location: ../../pages/marks.php?add-marks=yes");
// }
// else{
// echo "Error";
// header("location: ../../pages/marks.php?add-marks=error");
// }
}
?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With