Requète récupération de données

labourette Messages postés 657 Date d'inscription   Statut Membre Dernière intervention   -  
labourette Messages postés 657 Date d'inscription   Statut Membre Dernière intervention   -
Bonjour,
J'ai fait une requète qui récupére les infos de chaque membre qui se connecte à son espace.
J'ai affiché le SESSION du membre connecté cela fonctionne, mais ma requète je ne comprends pas pourquoi rien ne fonctionne. Pouvez vous me donner votre avis s'ils vous plait.
Je vous remercie de tout coeur et vous souhaite une très bonne année 2014.

<?php echo $_SESSION['prenom'] . ' ' . $_SESSION['nom']; ?><br /><?php

if (isset($_SESSION['login']) && $_SESSION['login'] != NULL)
{
   $login = $_SESSION['login'];
   $requete = $bdd->prepare ("SELECT * FROM t_gestion_adherent WHERE login='$login'");
   $requete->execute();
   
   while ($donnees = $requete->fetch(PDO::FETCH_ASSOC)) {

}
?>

<h2>Mon espace</h2>

 <table id="mon_profil" border="3">
	<tr>
		<th>Nom</th>
		<th>Prénom</th>
		<th>Adresse</th>
		<th>Code Postal</th>
		<th>Ville</th>
		<th>Tél. Fixe</th>
		<th>Tél. Portable</th>
		<th>Email</th>
		<th>Login</th>  
		<th>Mot de passe</th>
	</tr>
	<tr>
		<td><?php echo $donnees['nom']; ?></td>
		<td><?php echo $donnees['prenom']; ?></td>
		<td><?php echo $donnees['adresse']; ?></td>
		<td><?php echo $donnees['code_postal']; ?></td>
		<td><?php echo $donnees['ville']; ?></td>
		<td><?php echo $donnees['telephone_fixe']; ?></td>
		<td><?php echo $donnees['telephone_mobile']; ?></td>
		<td><?php echo $donnees['adresse_mail']; ?></td>
		<td><?php echo $donnees['login']; ?></td>    
		<td><?php echo $donnees['pass']; ?></td>
	</tr>
</table>
<?php
$requete->closeCursor();
}
?>

5 réponses

Manureva9962 Messages postés 21 Date d'inscription   Statut Membre Dernière intervention  
 
Bonjour,

J'ai vaguement suivi un début de formation HTML donc très très loin d'être une pro.
Je suis juste étonnée par l'inversion des accolades lignes 9 et 11.

Bonne année.
0
labourette Messages postés 657 Date d'inscription   Statut Membre Dernière intervention   6
 
Bonjour
en fait l'accolade l'ouverture de l'accolade ligne 9 et sa fermeture ligne 45
ensuite avec le if ligne 4 et fermeture ligne 11

Au plaisir
0
labourette Messages postés 657 Date d'inscription   Statut Membre Dernière intervention   6
 
J'ai remodifié ma requète elle ne fonctionne toujours pas si toute fois vous avez une idée.
Je vous remercie

<?php echo $_SESSION['prenom'] . ' ' . $_SESSION['nom']; ?><br />

<?php
if (isset($_SESSION['login']) && $_SESSION['login'] != NULL)
{
    $login = $_SESSION['login'];
    $reponse = $bdd->prepare ("SELECT * FROM t_gestion_adherent WHERE login='$login'");
    $reponse->execute();
    $donnees = $reponse->fetch(PDO::FETCH_ASSOC);
}
?>
<h2>Mon espace</h2>

 <table id="mon_profil" border="3">
	<tr>
		<th>Nom</th>
		<th>Prénom</th>
		<th>Adresse</th>
		<th>Code Postal</th>
		<th>Ville</th>
		<th>Tél. Fixe</th>
		<th>Tél. Portable</th>
		<th>Email</th>
		<th>Login</th>  
		<th>Mot de passe</th>
	</tr>
	<tr>
		<td><?php echo $donnees['nom']; ?></td>
		<td><?php echo $donnees['prenom']; ?></td>
		<td><?php echo $donnees['adresse']; ?></td>
		<td><?php echo $donnees['code_postal']; ?></td>
		<td><?php echo $donnees['ville']; ?></td>
		<td><?php echo $donnees['telephone_fixe']; ?></td>
		<td><?php echo $donnees['telephone_mobile']; ?></td>
		<td><?php echo $donnees['adresse_mail']; ?></td>
		<td><?php echo $donnees['login']; ?></td>    
		<td><?php echo $donnees['pass']; ?></td>
	</tr>
</table>
<?php
$reponse->closeCursor();
?>
0
JooS Messages postés 2468 Date d'inscription   Statut Membre Dernière intervention   228
 
Salut,

Utilisez la fonction "empty" au lieu de "isset + comparaison avec NULL".
L'affichage du profil doit être fait à l'intérieur de la condition.
Trés mauvaise voir fausse utilisation des requêtes préparés.
$reponse = $bdd->prepare ('SELECT * FROM t_gestion_adherent WHERE login = ?');
$reponse->execute(array($login));

Etes vous sure que $_SESSION['login'] n'est pas vide ?
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
labourette Messages postés 657 Date d'inscription   Statut Membre Dernière intervention   6
 
Bonjour.
Merci de vos réponses.
Cela fonctionne.
Merci


Bonjour <?php echo $_SESSION['prenom']; ?>...Complète ou Modifie tes infos, Merci<br />
  <ul>
      <li><a href="index.php?body=deconnexion&type=accueil">Se Déconnecter</a></li>
  </ul>

<?php
if (isset($_SESSION['login']) && $_SESSION['login'] != NULL) {
   $login = $_SESSION['login'];
   $reponse = $bdd->prepare   ("
                              SELECT t_gestion_adherent.id_adherent, t_gestion_adherent.civilite, t_gestion_adherent.nom, t_gestion_adherent.prenom, t_gestion_adherent.adresse_mail, t_gestion_adherent.date_naissance, t_gestion_adherent.telephone_fixe, t_gestion_adherent.telephone_mobile, t_gestion_adherent.adresse, t_gestion_adherent.lieu_dit, t_gestion_adherent.code_postal, t_gestion_adherent.ville, t_identifiant.login, t_identifiant.pass
                              FROM t_gestion_adherent
                              LEFT JOIN t_identifiant
                              ON t_gestion_adherent.id_adherent = t_identifiant.rid_adherent
                              WHERE login='$login'
                              ");
   $reponse->execute();
   $donnees = $reponse->fetch(PDO::FETCH_ASSOC);
}
?>

<h2>Mon espace</h2>

<table id="mon_profil" border="3">
   <tr>
      <th>Civilité(e)</th>
      <th>Nom</th>
      <th>Prénom</th>
      <th>Adresse Mail</th>
      <th>Date Naissance</th>
      <th>Tél. Fixe</th>
      <th>Tél. Mobile</th>
   </tr>
   <tr>
      <td><?php echo $donnees['civilite']; ?></td>
      <td><?php echo $donnees['nom']; ?></td>
      <td><?php echo $donnees['prenom']; ?></td>
      <td><?php echo $donnees['adresse_mail']; ?></td>
      <td><?php echo dateFR($donnees['date_naissance']) ?></td>
	  <td><?php $tel = $donnees['telephone_fixe']; $tel = wordwrap ($tel, 2, ' ', 1); echo $tel;?></td>
	  <td><?php $tel = $donnees['telephone_mobile']; $tel = wordwrap ($tel, 2, ' ', 1); echo $tel;?></td>
   </tr>
</table>
<table id="mon_profil" border="3">
   <tr>
      <th>Adresse</th>
      <th>Lieu dit</th>
      <th>Code Postal</th>  
      <th>Ville</th>
      <th>Login</th>
      <th>Mot de passe</th>
   </tr>
   <tr>
      <td><?php echo $donnees['adresse']; ?></td>
      <td><?php echo $donnees['lieu_dit']; ?></td>    
      <td><?php echo $donnees['code_postal']; ?></td>
      <td><?php echo $donnees['ville']; ?></td>
      <td><?php echo $donnees['login']; ?></td>
      <td><?php echo $donnees['pass']; ?></td>
   </tr>
</table>
0