A voir également:
- Undefined index: id
- Notice: undefined index: id - Meilleures réponses
- Undefined index: - Meilleures réponses
- Notice: undefined index: id ✓ - Forum - Programmation
- PHP - Notice : Undefined index - Conseils pratiques - PHP
- Notice: Undefined index: id ✓ - Forum - PHP
- Php Notice: Undefined index: ✓ - Forum - PHP
- Notice: Undefined index ✓ - Forum - PHP
3 réponses
supernico
- Messages postés
- 513
- Date d'inscription
- dimanche 30 décembre 2007
- Statut
- Membre
- Dernière intervention
- 20 novembre 2011
Si tu ne mets pas le id= dans l'url il faut le gérer dans ta page !
ligne 16, pour savoir si on t'as passé un id dans l'url :
ligne 16, pour savoir si on t'as passé un id dans l'url :
if(isset($_GET['id'])) { // id dans l'url $id = $_GET['id']; } else { // pas de id dans l'url }
vince240986
Merci beaucoup, ta réponse m'a mené à ce que je voulais faire. Voici le code fonctionnel:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/ DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="fr-fr"> <head> <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" /> <link href="../style.css" rel="stylesheet" type="text/css"/> <title>Voir les catégories</title> </head> <body> <div id="moncadre"> <?php include('menu.php');?> <div class="cadrecentrale"> <h1>Voir les catégories</h1> <?php // on se connecte à la base de données include('../connexion_bd.php'); mysql_connect("$nom_du_serveur","$nom_utilisateur","$passe"); mysql_select_db("$nom_de_la_base") or die('Impossible de sélectionner une base de donnée. Assurez vous d\'avoir correctement remplit les données du fichier connexion_bd.php.'); if(isset($_GET['id'])) { $id = $_GET['id']; $result = mysql_query("SELECT id, id_categorie, titre FROM CONTENU WHERE id_categorie='$id' ORDER BY id ASC"); echo '<h1>Catégorie '.$id.'</h1>'; if(mysql_num_rows($result) == 0) { echo '<div class="cadre"><p>Aucun article pour le moment!</p></div>'; } else { echo '<table style="width: 100%;" cellpadding="2" cellspacing="2"> <tr> <td class="hauttd">Article</td> <td class="hauttd">Modifier</td> <td class="hauttd">Supprimer</td> </tr>'; while($affiche = mysql_fetch_array($result)) { echo '<tr><td><a href="http://'.$_SERVER['HTTP_HOST'].'/cms/page.php?id='.$affiche['id'].'">'.$affiche['titre'].'</a></td> <td><a href="modifier-article.php?id='.$affiche['id'].'"><img src="images/modifier.png" alt="Modifier"/></a></td> <td><a href="supprimer-article.php?id='.$affiche['id'].'"><img src="images/supprimer.png" alt="Supprimer"/></a></td></tr></table>'; } } } else { echo '<div class="cadre"><p>Aucun article pour le moment!</p></div>'; } ?> </div> <?php include('../footer.php');?> </div> </body> </html>