[php] 3

Viewer

  1. <?php
  2. $conn = mysqli_connect("localhost", "root", "", "uts");
  3.  
  4. function tampil($query)
  5. {
  6.     global $conn;
  7.     $result = mysqli_query($conn, $query);
  8.     $rows = [];
  9.     while ($row = mysqli_fetch_assoc($result)) {
  10.         $rows[] = $row;
  11.     }
  12.     return $rows;
  13. }
  14.  
  15. function ubah($data)
  16. {
  17.     global $conn;
  18.  
  19.     $id = $data["idSensor"];
  20.     $namaMeja = $data["noMeja"];
  21.     $statusMeja = $data["statusTombol"];
  22.  
  23.     $query = "UPDATE meja SET 
  24.                     noMeja = '$namaMeja',
  25.                     statusTombol = '$statusMeja'
  26.                 WHERE idSensor = $id
  27.             ";
  28.     mysqli_query($conn, $query);
  29.  
  30.     return mysqli_affected_rows($conn);
  31. }
  32.  
  33. function ubahPasien($data)
  34. {
  35.     global $conn;
  36.  
  37.     $id = $data["idSensor"];
  38.  
  39.     $query = "UPDATE sensor_warungmakan SET 
  40.                     statusTombol = 1
  41.                 WHERE idSensor = $id
  42.             ";
  43.     mysqli_query($conn, $query);
  44.  
  45.     return mysqli_affected_rows($conn);
  46. }

Editor

You can edit this paste and save as new:


File Description
  • 3
  • Paste Code
  • 30 Apr-2024
  • 995 Bytes
You can Share it: