I suggest you prepare instructions for updating to the for loop
$query = $db->prepare("UPDATE sc_marks SET get_marks=? WHERE _sid=? AND exam_type=?");
for ($key=0; $key < count($_POST['marks']); $key++) {
$from_marks = $_POST['from'][$key];
$get_marks = $_POST['marks'][$key];
if($get_marks > $from_marks){
echo "Cant add more marks <br/>";
}
else{
echo $get_marks."<br/>";
$query->execute($get_marks, $sc_foreign_id, $select_exam_type);
}
}
Your current approach is a security risk, in addition to being less effective than it can be. Read about SQL injection.
source
share