Advertisement
Guest User

Untitled

a guest
Mar 24th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. <?php
  2. // database settings
  3. $db_username = "****";
  4. $db_password = "****";
  5. $db_name = "****";
  6. $db_host = "****";
  7.  
  8.  
  9. //open connection to mysql db
  10. $connection = mysqli_connect("$db_host","$db_username","$db_password","$db_name") or die("Error " . mysqli_error($connection));
  11.  
  12. //fetch table rows from mysql db
  13. $sql = "select * from markers";
  14. $result = mysqli_query($connection, $sql) or die("Error in Selecting " . mysqli_error($connection));
  15.  
  16. //create an array
  17. $emparray = array();
  18. while($row =mysqli_fetch_assoc($result))
  19. {
  20. $emparray[] = $row;
  21. }
  22.  
  23.  
  24. $data = array($emparray);
  25.  
  26. echo json_encode($data);
  27. [enter image description here][1]
  28. //close the db connection
  29. mysqli_close($connection);
  30. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement