Guest User

Untitled

a guest
Jul 25th, 2018
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. <?php
  2. error_reporting(0);
  3.  
  4. $hostname = "host";
  5. $user = "user";
  6. $password = "****";
  7. $database = "BD";
  8.  
  9. $db = mysqli_connect($hostname, $user, $password) or die("Opps some thing went wrong");
  10. mysqli_select_db($database, $db) or die("Opps some thing went ERROR 2");
  11.  
  12. // array for JSON response
  13. $response = array();
  14.  
  15. // get all items from myorder table
  16.  
  17.  
  18. $result = mysqli_query("SELECT * FROM escolar_tracker ") or die(mysqli_error());
  19.  
  20. if (mysqli_num_rows($result) > 0) {
  21.  
  22. $response["rutas"] = array();
  23.  
  24. while ($row = mysqli_fetch_array($result)) {
  25. // temp user array
  26. $item = array();
  27. $item["id"] = $row["id"];
  28. $item["ruta"] = $row["ruta"];
  29. $item["jornada"] = $row["jornada"];
  30.  
  31. // push ordered items into response array
  32. array_push($response["rutas"], $item);
  33. }
  34. // success
  35. $response["success"] = 1;
  36. }
  37. else {
  38. // order is empty
  39. $response["success"] = 0;
  40. $response["message"] = "No Items Found";
  41. }
  42. // echoing JSON response
  43. echo json_encode($response);
  44.  
  45.  
  46. ?>
Add Comment
Please, Sign In to add comment