Requète préparée PDO avec boucle

Bonjour,

Je viens vers vous pour savoir si vous pouvez m'expliquer pourquoi cette requète ne fonctionne pas. Je voudrais tout simplement afficher les numéro de téléphone.
Je vous remercie beaucoup

<?php
$resultats = $bdd->prepare("SELECT t_gestion_adherent.id_adherent, t_gestion_adherent.telephone_fixe, t_gestion_adherent.telephone_mobile, t_identifiant.categorie_admin
                            FROM t_gestion_adherent
                            INNER JOIN t_identifiant
                            ON t_gestion_adherent.id_adherent = t_identifiant.rid_adherent
                            WHERE (((t_identifiant.categorie_admin)= 'Gestion Sortie'))");
$resultats->execute(array();
while $donnees = $resultats->setFetchMode(PDO::FETCH_OBJ)
{
?>
                <b><p style="margin: 5px; padding: 5px;">Prestations</p></b><?php echo $donnees->telephone_fixe.' '.$donnees->telephone_mobile; ?>
                <a href="index.php?body=sortie&type=contact"><img src="image/par_mail.png" width="80%" type="image" name="form_contact" class="form_contact" border="0" Value="" align="middle"/></a>
<?php
}

3 réponses

  1. Bonjour,
    Nickel je te remercie ça fonctionne super.

    Merci
    1. Salut,

      Essaye comme ceci :
      $resultats = $bdd->prepare("SELECT t_gestion_adherent.id_adherent, t_gestion_adherent.telephone_fixe, t_gestion_adherent.telephone_mobile, t_identifiant.categorie_admin
                                  FROM t_gestion_adherent
                                  INNER JOIN t_identifiant
                                  ON t_gestion_adherent.id_adherent = t_identifiant.rid_adherent
                                  WHERE t_identifiant.categorie_admin = 'Gestion Sortie'");
      $resultats->execute();
      while ($donnees = $resultats->fetchObject()) {
          var_dump($donnees);
      }
      


      -> ligne 5 : parenthèse inutile dans la clause where
      -> ligne 6 : erreur de syntaxe (manque une parenthèse) + paramètre inutile
      -> ligne 7 : utilisation de fetchObject()

      Bonne journée
      1. Bonjour,
        Je n'arrive pas à comprendre pourquoi ma requête ne fonctionne pas. Pouvez-vous s'ils vous plait et si vous avez un peu de temps me donner des explications sur ma requête préparée.
        En vous remerciant beaucoup.