voilà le script qui affiche seulement les categories parent
?php require_once('Connections/cnx.php'); ?> <?php mysql_select_db($database_cnx, $cnx); $query_catego = "SELECT nom FROM categories WHERE parent_id = 0"; $catego = mysql_query($query_catego, $cnx) or die(mysql_error()); $row_catego = mysql_fetch_assoc($catego); $totalRows_catego = mysql_num_rows($catego); ?> <html> <head> <title>Document sans titre</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head>
<body> <table border="1"> <tr> <td>nom</td> </tr> <?php do { ?> <tr> <td><?php echo $row_catego['nom']; ?></td> </tr> <?php } while ($row_catego = mysql_fetch_assoc($catego)); ?> </table>
</body> </html> <?php mysql_free_result($catego); ?>
seulement les noms des categories sont affiche dans un tableau
je désire transformer la ligne d'affichage <?php echo $row_catego['nom']; ?> en un lien afin d'afficher les sous categorie du parent
j'ai créé une table avec id, parent_id ou parent_id=id si appartenance à categorie
merci
michel
|