Jump to content

ralph03

New Members
  • Posts

    6
  • Joined

  • Last visited

Everything posted by ralph03

  1. 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"; } } ?>
  2. Thank you sir for your solution given. Can you please modify it using my share code above? This is due to I have an issue understanding the flow of your suggested code.Tq
  3. In this case, only $update3 is affected. $update3 = "UPDATE applicantabove18att SET staffno = '$staffno' WHERE appid = '$appid'"; Thank you for your suggestion, however, when I changed WHERE appid to appno, it didn't update even one row.
  4. Hi guys, based on image 1, I plan to update staffno in multiple rows based on appno. I aim to update staffno=3 with all appno=4. However, only 1 staffno updated. Here is the code: <?php if (isset($_POST['update_btn'])){ $staffno = $_POST['staffno']; // 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 appid = '$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{ ?> <script type="text/javascript"> alert("Please try again"); </script> <?php } } } ?> The code related is $update3. Please advise. Tq in advance
  5. True based on the warning. Do you have any idea how to solve this?or any code that you want to share much appreciated.
  6. Hi, I need help with file downloading. I aim to click the download button (refer 1.jpeg) and the system displays the file that needs to be downloaded. However, I have a problem to do that. When I click the download button, it appears warning: <a href="download.php?file=<br /><b>Warning</b>: Undefined array key 1 in <b>C:\xampp\htdocs\bercuitmsarawak\adminview4.php</b> on line <b>43</b><br /> " class="btn btn-primary"><span class="glyphicon glyphicon-download"></span> Download</a>. The problem is the code for fetching data in the attribute file in the database (refer 2.jpeg) is not working. So I need help you guys to looked for my code. TQSM interface code <table class="table table-bordered" border=5 cellpadding=5 cellspacing=0> <tr> <th>appno <th>flowchart <th>gantt <th>proposal <th>questionnaire <th>Action </tr> <?php require 'conn.php'; $stmt = $con->prepare("SELECT * FROM applicantabove18att"); $stmt->execute(); $result = $stmt->get_result(); while($fetch = $result->fetch_assoc()) { $filename = explode('/', $fetch['file']); ?> <tr> <td><?php echo $fetch['appno']; ?></td> <td><?php echo $fetch['flowchart']; ?></td> <td><?php echo $fetch['gantt']; ?></td> <td><?php echo $fetch['proposal']; ?></td> <td><?php echo $fetch['questionnaire']; ?></td> <td><a href="download.php?file=<?php echo $filename[1]?>" class="btn btn-primary"><span class="glyphicon glyphicon-download"></span> Download</a></td> </tr> <?php } ?> </table> download.php code <?php if (isset($_GET['file'])) { $file = $_GET['file']; $file_path = "dokumen/" . $file; // Modify path if needed if (file_exists($file_path)) { // Set download headers and read the file header("Content-Disposition: attachment; filename=" . $file); header("Content-Type: application/octet-stream;"); readfile($file_path); } else { echo "Error: File not found!"; // Display error message } } ?>
×
×
  • 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.