From: Jérôme Benoit Date: Sat, 20 Jan 2018 16:38:57 +0000 (+0100) Subject: Make the reservation(s) code more readable. X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=181c3ee47dbbd650216b0e39d6539dc2c6d2b811;p=Project_webapp.git Make the reservation(s) code more readable. Signed-off-by: Jérôme Benoit --- diff --git a/includes/formsearch.php b/includes/formsearch.php index cd12ee4..5cdca0c 100644 --- a/includes/formsearch.php +++ b/includes/formsearch.php @@ -132,7 +132,7 @@ if (!$input_failure) { echo " Réserver\n"; echo " \n"; foreach ($fligths as $fligth) { - $sql_pquery = "select sum(NbPlaces) from RESERVATIONS where NumVol = ?"; + $sql_pquery = "select sum(NbPlaces) as BookedPlaces from RESERVATIONS where NumVol = ?"; $connection->prepare_query($sql_pquery); $connection->prepared_query_bind_param("s", array($fligth['NumVol'])); $connection->run_prepared_query(); @@ -157,7 +157,7 @@ if (!$input_failure) { echo " " . $fligth['Classe'] . "\n"; echo " " . $fligth['Prix'] . "€\n"; echo " - Places libres : " . $free_places . " + Nombre de places libres : " . $free_places . "
diff --git a/includes/reservations.php b/includes/reservations.php index 0d32077..9458dc7 100644 --- a/includes/reservations.php +++ b/includes/reservations.php @@ -24,9 +24,9 @@ $connection->prepare_query($sql_pquery); $connection->prepared_query_bind_param("is", array($client_id, $date_now)); $connection->run_prepared_query(); $connection->get_pquery_result(); -$rows = $connection->get_result_array(); +$reservations = $connection->get_result_array(); $connection->close_prepared_query(); -if (empty($rows)) { +if (empty($reservations)) { echo "Aucune(s) réservation(s) en cours pour le moment.
"; } else { echo "\n"; @@ -41,24 +41,24 @@ if (empty($rows)) { echo " \n"; echo " \n"; echo " \n"; - foreach ($rows as $row) { - $oDepartureDate = new DateTime($row['DateD']); + foreach ($reservations as $reservation) { + $oDepartureDate = new DateTime($reservation['DateD']); echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; if ($oDepartureDate > $oDateNow) { echo " \n";
PrixActions
" . $row['NumVol'] . "" . $row['VilleD'] . "" . $row['DateD'] . "" . $row['VilleA'] . "" . $row['DateA'] . "" . $row['Classe'] . "" . $row['NbPlaces'] . "" . $row['Prix'] . "€" . $reservation['NumVol'] . "" . $reservation['VilleD'] . "" . $reservation['DateD'] . "" . $reservation['VilleA'] . "" . $reservation['DateA'] . "" . $reservation['Classe'] . "" . $reservation['NbPlaces'] . "" . $reservation['Prix'] . "€ - - - + + +