I have a table nested within a form that looks as follows:
The "leave_request_processor.php" file that receives the post request from the above file then reads as follows:
$approved = "Approved";
$rejected = "Rejected";
foreach($all_leave_ids as $leave_id){
if(isset($_POST["approve"])){
$strQuery2 = "UPDATE leave_applications SET status = '$approved' WHERE application_id = '$leave_id' ";
$result2 = mysqli_query($connection,$strQuery2) or Exit ("Query execution failed");
mysqli_close($connection);
header("Location: leave_check.php"); /* Redirect browser */
exit();
}
else if (isset($_POST["reject"])){
$strQuery3 = "UPDATE leave_applications SET status = '$rejected' WHERE application_id = '$leave_id' ";
$result3 = mysqli_query($connection,$strQuery3) or Exit ("Query execution failed");
mysqli_close($connection);
header("Location: leave_check.php"); /* Redirect browser */
exit();
}
}
The code works but starting with the first row (whichever rows' button you click) in descending order then the page reloads and you're left with the pending requests.
I bet there's a way you can code it (I'm thinking JavaScript) so that if I click "Approve" on row 23 it acts on that row. Anyone know how I can achieve this?