Hi everybody,
I want to do a menu showing my categories and sub_categories for each of them. Everything is working fine if i just want my categories but when i want to add the sub, i'm all mix up!
My tables are like that:
categorie:
id_cat
cat_name
cat_desc
sous_categorie:
id_sous_cat
sous_cat_name
sous_cat_desc
id_cat
i did a relation between the 2 tables where id_cat in sous_categorie is the same id_cat from categorie.
So here's my code for trying to get a menu (i didn't put any a href to make it simple for now) showing the categories and the sub-categorie for each of them.
But nothing is working and i have difficulties finding a good tuto where i can find what i'm doing wrong.
Can someone form here can be gentle to put me on the track?
<?php
$db = new mysqli('localhost','root','','eurodib');
$query = "select * from categorie, sous_categorie where id_cat.categorie = id_cat.sous_categorie";
$result = $db -> query($query);
?>
<ul>
<li>
Categories <br/>
<ul>
<?php
while($row = $result -> fetch_assoc())
{
$row['cat_name'] ."<br>";
echo "<li>";
}
echo "<ul>";
while ($row = $result -> fetch_assoc())
{
$row['sous_cat_name'] ."<br>";
echo "<li>";
}
echo "</li>";
echo "</ul>";
echo "</li>";
?>
</ul>
Thank you to help me!