Advertisement
Guest User

Untitled

a guest
Sep 18th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.93 KB | None | 0 0
  1. <?php
  2. define('DB_HOST', 'localhost');
  3. define('DB_USER', 'id10192535_razitul');
  4. define('DB_PASSWORD', 'hoki7878');
  5. define('DB_NAME', 'id10192535_rumah_sakit');
  6. $conn = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
  7. if(mysqli_connect_errno()){
  8.     echo 'Gagal terhubung ke database MySQL Server'.  mysqli_connect_error();
  9.     die();
  10. }
  11. $stat = $conn ->prepare("SELECT id,nama,alamat,nohp,website,latitude,longtitude,gambar FROM data ");
  12. $stat ->execute();
  13. $stat ->bind_result($id,$nama,$alamat,$nohp,$website,$latitude,$longtitude,$gambar);
  14. $rumahsakit = array();
  15. while ($stat ->fetch()){
  16.     $temp = array();
  17.     $temp['id']= $id;
  18.     $temp['nama']= $nama;
  19.     $temp['alamat']= $alamat;
  20.     $temp['nohp']= $nohp;
  21.     $temp['website']= $website;
  22.     $temp['latitude']= $latitude;
  23.     $temp['longtitude']= $longtitude;
  24.     $temp['gambar']= $gambar;
  25.     array_push($rumahsakit, $temp);
  26. }
  27. echo json_encode($rumahsakit);
  28.  
  29. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement