From 181c3ee47dbbd650216b0e39d6539dc2c6d2b811 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sat, 20 Jan 2018 17:38:57 +0100 Subject: [PATCH] Make the reservation(s) code more readable. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- includes/formsearch.php | 4 ++-- includes/reservations.php | 30 +++++++++++++++--------------- 2 files changed, 17 insertions(+), 17 deletions(-) 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"; -- 2.34.1
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'] . "€ - - - + + +