Guest User

Untitled

a guest
Mar 29th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. <?php
  2. $servername = "localhost";
  3. $username = "root";
  4. $password = "";
  5. $dbname = "learndb";
  6.  
  7. // Create connection
  8. $conn = new mysqli($servername, $username, $password, $dbname);
  9. // Check connection
  10. if ($conn->connect_error) {
  11. die("Connection failed: " . $conn->connect_error);
  12. }
  13.  
  14. $sql = "SELECT * FROM users";
  15. $result = $conn->query($sql);
  16.  
  17. $emparray = array();
  18.  
  19. while($row =mysqli_fetch_assoc($result))
  20. {
  21. $emparray[] = $row;
  22. }
  23.  
  24. echo json_encode($emparray);
  25.  
  26. $conn->close();
  27. ?>
Add Comment
Please, Sign In to add comment