123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <?PHP
-
- // ---------------
- // Connection to server and database
- // ---------------
-
- $host = "localhost";
- $basedatos = "techos";
- $user = "pablo.puig1";
- $passw = "9NA3kSExI2fGE6eV";
-
- try{
- $connection = mysqli_connect($host, $user, $passw, $basedatos) or $error = 1;
- }
- catch(Exception $ex){
- print("Error connecting to database: ". $ex->getMessage()) and die();
- }
-
- // //---------------
- // // Query and sending results
- // //---------------
- header('Content-Type: application/json');
-
- $encodedData=file_get_contents('php://input');
- $decodedData=json_decode($encodedData, true);
-
- $FindEID=$decodedData["FindEID"];
-
- $query= "SELECT eid, name, start_date, end_date, participant_count, participant_limit, description from events";
- $stmt=mysqli_prepare($connection, $query);
- mysqli_stmt_execute($stmt);
-
- mysqli_stmt_bind_result($stmt, $eid, $name, $start_date, $end_date, $participant_count, $participant_limit, $description);
-
- while(mysqli_stmt_fetch($stmt)){
-
- $response[] = array("id"=>$eid, "activityName"=>$name, "subscribed"=> false, "icon"=> 'person-add-outline', "startDate"=>$start_date, "endDate"=>$end_date, "totalSubscribed"=>$participant_count, "maxSubscribed"=>$participant_limit, "activityDescription"=>$description);
-
- }
-
-
- // if(mysqli_num_rows($stmt)>0)
- // {
- // $Row = mysqli_fetch_assoc($stmt);
- // $eid = $Row['eid'];
- // $name = $Row['name'];
- // $start_date = $Row['start_date'];
- // $end_date = $Row['end_date'];
- // $participant_count = $Row['participant_count'];
- // $participant_limit = $Row['participant_limit'];
- // $description = $Row['description'];
- // }
- // else
- // {
- // $eid = "";
- // $name = "";
- // $start_date = "";
- // $end_date = "";
- // $participant_count = "";
- // $participant_limit = "";
- // $description = "";
- // }
-
-
- // ----------------------------------------------
- // $eid = '1';
- // $name = 'testEvent';
- // $start_date = '2023-01-07';
- // $end_date = '2023-01-23';
- // $participant_count = '13';
- // $participant_limit = '20';
- // $description = 'TEST TEST TEST TEST TEST TEST TEST TEST';
- //-----------------------------------------------
-
- // $response[] = array("eid"=>$eid, "name"=>$name, "Sdate"=>$start_date, "Edate"=>$end_date, "Pcount"=>$participant_count, "Plimit"=>$participant_limit, "description"=>$description);
- echo json_encode($response);
- // $TPMGJson = json_encode($response);
- // file_put_contents('./events.json', $TPMGJson);
- // echo $TPMGJson;
-
- ?>
|