Good evening.
I need to put together a dynamic, three-table menu that needs to be interconnected, but I'm lost. Here's a part of the organization chart below:
Atthemoment,Ihavethefollowingcode:
<liclass="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Produtos<span class="caret"></span></a>
<ul class="dropdown-menu">
<li class="dropdown dropdown-submenu"><a class="dropdown-toggle" href="#" data-toggle="dropdown">Audiologia</a>
<ul class="dropdown-menu">
<?php
require 'conexao.php';
$consulta = $PDO->query("SELECT * FROM subcategoria WHERE categoria_id = '1' ORDER BY ID;");
while ($linha = $consulta->fetch(PDO::FETCH_ASSOC)) { ?>
<li><a href="produto.php?id=<?php echo "$linha[id]"; ?>"><?php echo "$linha[titulo]"; ?></a></li>
<?php } ?>
<ul class="dropdown-menu">
<?php
require 'conexao.php';
$consulta = $PDO->query("SELECT * FROM produto WHERE categoria_id = '1' AND subcategoria_id = '1' ORDER BY ID;");
while ($linha = $consulta->fetch(PDO::FETCH_ASSOC)) { ?>
<li><a href="produto.php?id=<?php echo "$linha[id]"; ?>"><?php echo "$linha[titulo]"; ?></a></li>
<?php } ?>
</ul>
</ul>
</li>
In my database, I have the tables:
CATEGORIES = with the main categories, ID and CATEGORY.
SUBCATEGORIES = with the ID, CATEGORY_ID and SUBCATEGORY fields.
PRODUCT = with fields ID, CATEGORY_ID, SUBCATEGORIA_ID and TITLE.
I can, from this code, have the category and the sub category, but not the product. I do not think this is the right way to do it, I would like instructions.