Jump to content

ralph03

New Members
  • Posts

    6
  • Joined

  • Last visited

Community Answers

  1. ralph03's post in update multiple rows based on the same appno was marked as the answer   
    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";
     
    }
    }
     
    ?>
     
     
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.