Bonjour,
j'intervient sur un forum car j'ai un petit soucis d'affichage, enfaite mon foreach pour afficher mes reservation ne m'affiche q'un resultat au lieux de deux alors que il devrait en afficher deux par exemple :
| idReservation | date_heure_Reservation | nbPersonnes | statut | idResto | idClient |
+---------------+------------------------+-------------+------------+---------+----------+
| 1 | 2017-02-15 03:06:45 | 3 | En attente | 1 | 6 |
| 2 | 2017-02-23 12:14:02 | 3 | validé | 3 | 6
la mon client à effectuer deux reservation mais il n'est afficher que la première réservation et non la deuxième et je voudrais qu'est ce qui cloche dans mon code
Ce que je fais
Code : Vue mesReservations.php
if(is_array($unResultat))
{
foreach (array($unResultat) as $maReservation)
{
echo"
<table class=table>
<thead>
<tr class=success>
<th> date et heure de la reservation : </th>
<th> Nombre de Personnes : </th>
<th> statut de la reservation : </th>
</tr>
</thead>
<tbody>
<tr>
<td> ".$maReservation['date_heure_Reservation']." </td>
<td> ".$maReservation['nbPersonnes']." </td>
<td> ".$maReservation['statut']." </td>
</tr>
</tbody>
</table>
";
}
}
Code : mesReservation.php
<?php
include("MVC_PHP/Controleur/Controleur_site.php");
$Controleur = new affichageResto("localhost", "restline", "root", "");
$where = array(
"idClient" => $_SESSION['idClient']
);
$champs = array("date_heure_Reservation", "nbPersonnes", "statut");
$unResultat = $Controleur-> AffichageMaReservation($champs, $where);
include("MVC_PHP/Vues/Vues_mesReservation.php");
?>
code var_dump de l'affichage
C:\wamp64\www\Projet_php\Resline_site\MVC_PHP\Modele\Modele_site.php:60:
object(PDOStatement)[4]
public 'queryString' => string 'select date_heure_Reservation,nbPersonnes,statut from reservation where idClient= :idClient;' (length=95)
C:\wamp64\www\Projet_php\Resline_site\MVC_PHP\Modele\Modele_site.php:62:
array (size=6)
'date_heure_Reservation' => string '2017-03-12 12:13:28' (length=19)
0 => string '2017-03-12 12:13:28' (length=19)
'nbPersonnes' => string '2' (length=1)
1 => string '2' (length=1)
'statut' => string 'En attente' (length=10)
2 => string 'En attente' (length=10)
Ce que je veux
que deux resultats s'affiche correpondant à l'id du client donc;
date et heure de la reservation : Nombre de Personnes : statut de la reservation :
2017-02-15 03:06:45 3 En attente
2017-02-23 12:14:02 3 Validé
Ce que j'obtiens
juste 1 resultat qui est :
date et heure de la reservation : Nombre de Personnes : statut de la reservation :
2017-02-15 03:06:45 3 En attente