SHARE
TWEET

Proyek Web Untuk Di Windows

stevennathaniel Nov 25th, 2018 (edited) 88 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. $kodebarang = 'xx.xxx.xxx';
  4.  
  5. $koneksi = mysqli_connect('localhost','xxxx','xxxx','xxxx');
  6.  
  7. if (!$koneksi) {
  8.  
  9.     echo "Gagal Terhubung ke Database. " . PHP_EOL;
  10.     echo "Debugging errno : " . mysqli_connect_errno() . PHP_EOL;
  11.     echo "Debugging error : " . mysqli_connect_error() . PHP_EOL;
  12.  
  13. }
  14.  
  15. /**
  16.  
  17. echo "Berhasil Terkoneksi ke Database." . PHP_EOL;
  18.  
  19. echo "<br>";
  20.  
  21. echo "Informasi Server : " . mysqli_get_host_info($koneksi) . PHP_EOL;
  22.  
  23. echo "<br>";
  24.  
  25. */
  26.  
  27. $cariData = $koneksi->prepare("SELECT komputer.hostname,komputer.ipaddress,komputer.macaddress FROM komputer WHERE komputer.kodebarang=?");
  28.  
  29. $cariData->bind_param("s",$kodebarang);
  30.  
  31. $cariData->execute();
  32.  
  33. $hasilPencarian = $cariData->get_result();
  34.  
  35. $arrayJSON = array();
  36.  
  37. while($barisData = $hasilPencarian->fetch_array(MYSQLI_ASSOC)) {
  38.  
  39.     $arrayJSON[] = $barisData;
  40. }
  41.  
  42. // echo json_encode($arrayJSON);
  43.  
  44. echo json_encode($arrayJSON);
  45.  
  46. $cariData->close();
  47.  
  48. $koneksi->close();
  49.  
  50. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top