Advertisement
Guest User

Untitled

a guest
Jun 2nd, 2015
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. <?php
  2. header("Access-Control-Allow-Origin: *");
  3. header("Content-Type: application/json; charset=UTF-8");
  4.  
  5. $conn = new mysqli("db573884642.db.1and1.com", "dbo573884642", "hS2zKN@hEZyM", "db573884642");
  6.  
  7. $result = $conn->query("SELECT EmployeeName, teaTally, coffeeTally FROM Customers");
  8.  
  9. $outp = "[";
  10. while($rs = $result->fetch_array(MYSQLI_ASSOC)) {
  11. if ($outp != "[") {$outp .= ",";}
  12. $outp .= '{"Name":"' . $rs["EmployeeName"] . '",';
  13. $outp .= '"Teas":"' . $rs["teaTally"] . '",';
  14. $outp .= '"Coffees":"'. $rs["coffeeTally"] . '"}';
  15. }
  16. $outp .="]";
  17.  
  18. $conn->close();
  19.  
  20. echo($outp);
  21. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement