Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1531 connectés 

  FORUM HardWare.fr
  Programmation
  PHP

  Php et Join SQL

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

Php et Join SQL

n°2065365
adeel-fbf
Posté le 22-03-2011 à 21:13:08  profilanswer
 

Salut a tous,
 
voici mon code :  
 

Code :
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  5. <title>Document sans nom</title>
  6. </head>
  7. <body>
  8. <?php
  9. if (isset($_POST['valider']))
  10. {
  11. try
  12. {   
  13. $nom = $_POST['nom'];
  14. extract($_POST);
  15.     // On se connecte à MySQL
  16.     $pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
  17.     $bdd = new PDO('mysql:host=localhost;dbname=DSGF', 'root', 'thegame', $pdo_options);
  18.  
  19. $reponse = $bdd->query("SELECT * FROM Sous_Familles JOIN Articles ON Articles.type=Sous_Familles.nom WHERE Sous_Familles.nom='$nom'" );
  20.    
  21.    
  22.     // On affiche chaque entrée une à une
  23.     while ($donnees = $reponse->fetch())
  24.     {
  25.     ?>
  26.         <p>
  27. <strong><?php echo $donnees['Sous_Familles.detail1']; ?>: <?php echo $donnees['Articles.detail1']; ?><br /></strong>
  28. <strong><?php echo $donnees['Sous_Familles.detail2']; ?>: <?php echo $donnees['Articles.detail2']; ?><br /></strong>
  29. <strong><?php echo $donnees['Sous_Familles.detail3']; ?>: <?php echo $donnees['Articles.detail3']; ?><br /></strong>
  30. <strong><?php echo $donnees['Sous_Familles.detail4']; ?>: <?php echo $donnees['Articles.detail4']; ?><br /></strong>
  31. <strong><?php echo $donnees['Sous_Familles.detail5']; ?>: <?php echo $donnees['Articles.detail5']; ?><br /></strong>
  32. <strong><?php echo $donnees['Sous_Familles.detail6']; ?>: <?php echo $donnees['Articles.detail6']; ?><br /></strong>
  33.         </p>
  34.     <?php
  35.     }
  36.    
  37.     $reponse->closeCursor(); // Termine le traitement de la requête
  38. }
  39. catch(Exception $e)
  40. {
  41.     // En cas d'erreur précédemment, on affiche un message et on arrête tout
  42.     die('Erreur : '.$e->getMessage());
  43. }
  44. }
  45. ?>
  46. <form id="suppr-family" method="post" action="">
  47. <label>Veuillez entrer le type de sous familles : </label>
  48. <input id="nom" name="nom" type="text" />
  49. <input type="submit" name="valider"/>
  50. </form><br/>
  51. </body>
  52. </html>


 
Lorsque j'execute mon code j'ai cette erreur :
 

Citation :


Notice: Undefined index: Sous_Familles.detail1 in /opt/lampp/htdocs/test/ptdr.php on line 34
:  
Notice: Undefined index: Articles.detail1 in /opt/lampp/htdocs/test/ptdr.php on line 34
 
 
Notice: Undefined index: Sous_Familles.detail2 in /opt/lampp/htdocs/test/ptdr.php on line 35
:  
Notice: Undefined index: Articles.detail2 in /opt/lampp/htdocs/test/ptdr.php on line 35
 
 
Notice: Undefined index: Sous_Familles.detail3 in /opt/lampp/htdocs/test/ptdr.php on line 36
:  
Notice: Undefined index: Articles.detail3 in /opt/lampp/htdocs/test/ptdr.php on line 36
 
 
Notice: Undefined index: Sous_Familles.detail4 in /opt/lampp/htdocs/test/ptdr.php on line 37
:  
Notice: Undefined index: Articles.detail4 in /opt/lampp/htdocs/test/ptdr.php on line 37
 
 
Notice: Undefined index: Sous_Familles.detail5 in /opt/lampp/htdocs/test/ptdr.php on line 38
:  
Notice: Undefined index: Articles.detail5 in /opt/lampp/htdocs/test/ptdr.php on line 38
 
 
Notice: Undefined index: Sous_Familles.detail6 in /opt/lampp/htdocs/test/ptdr.php on line 39
:  
Notice: Undefined index: Articles.detail6 in /opt/lampp/htdocs/test/ptdr.php on line 39


 
Quelqu'un peut m'aider svp?
 
merci :D

mood
Publicité
Posté le 22-03-2011 à 21:13:08  profilanswer
 

n°2065371
skeye
Posté le 22-03-2011 à 22:16:37  profilanswer
 

Le message est on ne peut plus clair...ton tableau $donnees n'est pas rempli comme tu l'espères.


---------------
Can't buy what I want because it's free -
n°2065373
adeel-fbf
Posté le 22-03-2011 à 22:23:12  profilanswer
 

Comment je fais pour récupérer mes variables alors..? :(

n°2065376
skeye
Posté le 22-03-2011 à 22:37:38  profilanswer
 

Tu regardes ce que retourne vraiment ton fetch.[:dawak]


---------------
Can't buy what I want because it's free -

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  PHP

  Php et Join SQL

 

Sujets relatifs
Paiment enligne PHPGénération de fichier XML avec PhP
Erreur SQL[SQL][Resolu] requete imbriqué
Blog : PHP et css - Formatage d'un article[Résolu] Proteger son code PHP
Moteur de recherche perso en PHP : soucis avec des accents.MySQL + PHP Tourne pas rond
XML - PHP... API Flickr [RESOLU][resolu] problème d'injection SQL, doctrine orm
Plus de sujets relatifs à : Php et Join SQL


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR