-5
Hello, I’m trying to list the Sub-Categories within their respective Categories with Inner Join, but I’m not getting it, see what’s happening with the Categories menu.
Below I relate the code used...
<?php
include "../conexao.php";
$codigo = $_POST['codigo'];
$nome_cat = $_POST['nome_cat'];
$nome = $_POST['nome'];
$query = mysql_query("SELECT * FROM categoria INNER JOIN sub_categoria ON categoria.nome_cat = sub_categoria.nome_cat")or die(mysql_error());
while ($res = mysql_fetch_array($query)){
?>
<ul>
<li><a href="#"> <?php echo $nome_cat = $res['nome_cat'];?> </a>
<ul>
<li><a href="prod_index_categoria.php?codcategoria=<?php echo $res['nome'];?>"><?php echo $res['nome'];?></a></li>
</ul>
</li>
<?php
}
?>
</ul>
Below I relate images of table structures...
Category:
Sub-category:
If friends can help me solve the problem by making Categories not duplicate, and Sub-Categories fall within their respective Categories, I would be most grateful.
It worked perfect Mastria... Thank you very much for the solution and the tip, because I will take a look very carefully in the article indicated by you. THANK-YOU!!!!!
– Murilo Cabral