Advertisement
Guest User

Untitled

a guest
Jan 26th, 2019
985
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. <?php
  2. header('Access-Control-Allow-Origin: *');
  3. header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS');
  4. header('Access-Control-Allow-Credentials: true');
  5. header('Access-Control-Allow-Headers: X-Requested-With, Content-Type, Accept');
  6. header('Content-Type: application/json, charset=UTF-8');
  7. $hostname = "localhost:3306";
  8. $database = "Website_execrise";
  9. $username = "Website";
  10. $password = "6y805maCvrfZS65p";
  11.  
  12. $conn = isset($conn) ? $conn : mysqli_connect($hostname, $username, $password, $database) or die("Failed: " . mysqli_connect_error());
  13.  
  14. $arr = array();
  15. $result = mysqli_query($conn,"SELECT * FROM CLUB");
  16. $num = mysqli_num_rows($result);
  17. if ($num > 0) {
  18. while($row = mysqli_fetch_array($result,MYSQLI_ASSOC)) {
  19. $arr2 = array('familyname'=>$row['familyname'],'givenname'=>$row['givenname']
  20. ,'sex'=>$row['sex'],'phone'=>$row['phone'],'sport'=>$row['sport'],'level'=>$row['level']);
  21. array_push($arr,$arr2);
  22. }
  23. }
  24. echo json_encode($arr);
  25. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement