Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //Koneksi ke DB
- $host = "localhost";
- $user = "root";
- $password = "";
- $database = "ucup";
- $koneksi = mysqli_connect($host,$user,$password,$database);
- if($koneksi->connect_error){die("Koneksi gagal");}
- //Akhir Koneksi ke DB
- $hasil = mysqli_query($koneksi,"select * from admin");
- if(mysqli_num_rows($hasil) > 0 )
- {
- $response = array();
- while($x = mysqli_fetch_array($hasil))
- {
- $h['username'] = $x["username"];
- $h['password'] = $x["password"];
- array_push($response, $h);
- }
- header('Content-type: application/json');
- echo json_encode($response);
- }
- else
- {
- echo "Data tidak tersedia";
- }
- ?>
Add Comment
Please, Sign In to add comment