ralph03's post in update multiple rows based on the same appno was marked as the answer
June 26, 2024
Ok, finally I got the solution. The code is as below for sharing. Thanks guys for your help!
<?php
if (isset($_POST['update_btn'])){
if (!empty($_POST['staffno'])) {
$staffno = trim($_POST['staffno']);
$appno = $_POST['appno']; // ID of the record to be updated
$update = "UPDATE applicantabove18p2
SET staffno = '$staffno'
WHERE appid = '$appid'";
$update1 = "UPDATE applicantabove18p1
SET staffno = '$staffno'
WHERE appid = '$appid'";
$update2 = "UPDATE applicantabove18p1a
SET staffno = '$staffno'
WHERE appid = '$appid'";
$update3 = "UPDATE applicantabove18att
SET staffno = '$staffno'
WHERE appno = '$appid'";
if (mysqli_query($con, $update) && mysqli_query($con, $update1) && mysqli_query($con, $update2) && mysqli_query($con, $update3)) {
if ($data){
?>
<script type="text/javascript">
alert("Data updated successfully");
window.open("coordinatorview3.php","_self")
</script>
<?php
}
} else {
echo "Update failed: " . mysqli_error($con);
}
} else {
echo "Staff number cannot be empty";
}
}
?>