Notice: Undefined index: id

Résolu
gasol2 Messages postés 4 Date d'inscription   Statut Membre Dernière intervention   -  
totoyo47 Messages postés 260 Date d'inscription   Statut Membre Dernière intervention   -
Bonjour,

Je rencontre un problème que j'ai du mal à comprendre.
Undefined index: id in C:\wamp\www\projet\indexx.php on line 50
Undefined index: id in C:\wamp\www\projet\indexx.php on line 52




<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <link   href="css/bootstrap.min.css" rel="stylesheet">
    <script src="js/bootstrap.min.js"></script>
</head>

<body>
<div class="container">
    <?php
$date = date("d-m-Y");
$heure = date("H:m");
echo "Nous sommes le $date et il est $heure";
?>
       
    <h3>Afficher la liste des chambre</h3>
<p>
    <a href="create.php" class="btn btn-success" name="a">Ajouter</a> 
    <a href="index.php" class="btn btn-info" name="b" ><span class="glyphicon glyphicon-off" aria-hidden="true"></span></a>
</p>
<table class="table table-striped table-bordered">              
       <tr>
          <th>Nom </th>
          <th>prenom</th>
          <th>TEL</th>                    
          <th>date d'arrivée</th>
          <th>date départ</th>
          <th>type chambre</th>
          <th>action</th>
        </tr>
        <?php
        mysql_connect("localhost","root","") or die ("Oops! Server not connected"); // Connect to the host
        mysql_select_db("projet");
       // $sql=mysql_query("select client.nom,client.prenom,client.tel,reservation.date_r,reservation.date_d,typechm.nom_type from client,reservation,typechm where client.code_r=reservation.coder and client.code_type=typechm.code_type");
        

  $sql = mysql_query("SELECT client.nom,client.prenom,client.tel,reservation.date_r,reservation.date_d,typechm.nom_type FROM client,reservation,typechm WHERE client.id=reservation.coder and client.id=typechm.code_type") or die(mysql_error());
        //$sql = mysql_query("SELECT table1.column1, table2.column2 FROM table1, table2 WHERE table1.column1 = table2.column1");
        while($row=mysql_fetch_array($sql)){;
        echo"<tr>";
        echo"<th>$row[nom]</th>";
        echo"<th>$row[prenom]</th>";
        echo"<th>$row[tel]</th>";                    
        echo"<th>$row[date_r]</th>";
        echo"<th>$row[date_d]</th>";                    
        echo"<th>$row[nom_type]</th>";      
        echo "<td width=150>";
               echo ' ';
               echo '<a class="btn btn-success" href="update.php?edit='.$row['id'].'"><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span></a>';
                echo '  ';
               echo '<a class="btn btn-danger" href="delet.php?del='.$row['id'].'"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></a>';
       
    echo'</th>';
        echo'</tr>';
  }
  

?>
</table>
</div>


EDIT : Ajout des balises de code (la coloration syntaxique).
Explications disponibles ici : ICI

Merci d'y penser dans tes prochains messages.

1 réponse

totoyo47 Messages postés 260 Date d'inscription   Statut Membre Dernière intervention   134
 
Salut,

Undefined index: id in C:\wamp\www\projet\indexx.php on line 50
Undefined index: id in C:\wamp\www\projet\indexx.php on line 52


Le message d'erreur te dit qu'il ne trouve pas l'index 'id'.
Quand on va aux lignes correspondantes (line 50 et 52), on constate que l'erreur concerne la variable $row['id']. $row correspond à une ligne des résultats de ta requête $sql.
Or, tu ne sélectionnes pas la colonne 'id' dans ta requête. Tu dois donc ajouter après ton Select ceci : 'client.id'. Ton erreur devrait disparaitre.
0
gasol2 Messages postés 4 Date d'inscription   Statut Membre Dernière intervention  
 
Merci beaucoup, ta réponse m'a mené à ce que je voulais faire
0
totoyo47 Messages postés 260 Date d'inscription   Statut Membre Dernière intervention   134
 
Avec plaisir ;)
0