No Description

userslist.php 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?PHP
  2. // ---------------
  3. // Connection to server and database
  4. // ---------------
  5. $host = "localhost";
  6. $basedatos = "techos";
  7. $user = "pablo.puig1";
  8. $passw = "9NA3kSExI2fGE6eV";
  9. try{
  10. $connection = mysqli_connect($host, $user, $passw, $basedatos) or $error = 1;
  11. }
  12. catch(Exception $ex){
  13. print("Error connecting to database: ". $ex->getMessage()) and die();
  14. }
  15. // //---------------
  16. // // Query and sending results
  17. // //---------------
  18. header('Content-Type: application/json');
  19. $encodedData=file_get_contents('php://input');
  20. $decodedData=json_decode($encodedData, true);
  21. $FindUID=$decodedData["FindUID"];
  22. $query= "SELECT UID, acc_type, name, email, phone_num from users";
  23. $stmt=mysqli_prepare($connection, $query);
  24. mysqli_stmt_execute($stmt);
  25. mysqli_stmt_bind_result($stmt, $uid, $acc_type, $name, $email, $phone);
  26. while(mysqli_stmt_fetch($stmt)){
  27. $response[] = array("id"=>$uid, "accountType"=>$acc_type, "name"=> $name, "email"=> $email, "phone"=>$phone);
  28. }
  29. // if(mysqli_num_rows($stmt)>0)
  30. // {
  31. // $Row = mysqli_fetch_assoc($stmt);
  32. // $eid = $Row['eid'];
  33. // $name = $Row['name'];
  34. // $start_date = $Row['start_date'];
  35. // $end_date = $Row['end_date'];
  36. // $participant_count = $Row['participant_count'];
  37. // $participant_limit = $Row['participant_limit'];
  38. // $description = $Row['description'];
  39. // }
  40. // else
  41. // {
  42. // $eid = "";
  43. // $name = "";
  44. // $start_date = "";
  45. // $end_date = "";
  46. // $participant_count = "";
  47. // $participant_limit = "";
  48. // $description = "";
  49. // }
  50. // ----------------------------------------------
  51. // $eid = '1';
  52. // $name = 'testEvent';
  53. // $start_date = '2023-01-07';
  54. // $end_date = '2023-01-23';
  55. // $participant_count = '13';
  56. // $participant_limit = '20';
  57. // $description = 'TEST TEST TEST TEST TEST TEST TEST TEST';
  58. //-----------------------------------------------
  59. // $response[] = array("eid"=>$eid, "name"=>$name, "Sdate"=>$start_date, "Edate"=>$end_date, "Pcount"=>$participant_count, "Plimit"=>$participant_limit, "description"=>$description);
  60. echo json_encode($response);
  61. // $TPMGJson = json_encode($response);
  62. // file_put_contents('./events.json', $TPMGJson);
  63. // echo $TPMGJson;
  64. ?>