Advertisement
Guest User

PHP files

a guest
May 29th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. connection.php
  2. <?php
  3. $db_name = "aplikacja treningowa";
  4. $mysql_username = "root";
  5. $mysql_password = "";
  6. $server_name = "localhost";
  7. $connection = mysqli_connect($server_name, $mysql_username, $mysql_password, $db_name);
  8. ?>
  9.  
  10. get_all.php
  11. <?php
  12. require "connection.php";
  13. $response = array();
  14. $mysql_query = "SELECT *FROM map_data";
  15. $result = mysqli_query($connection, $mysql_query);
  16. if(mysqli_num_rows($result) > 0) {
  17. $response["map_data"] = array();
  18. while($row = mysqli_fetch_array($result)) {
  19. $stat = array();
  20. $stat["id"] = $row[0];
  21. $stat["mode"] = $row[1];
  22. $stat["distance"] = $row[2];
  23. $stat["calories"] = $row[3];
  24. array_push($response["map_data"], $stat);
  25. }
  26. $response["success"] = 1;
  27. }
  28. $connection->close();
  29. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement