Good evening guys, I need a little help I ended up here in PHP, it's the following, I created two tables category and area, each category has several areas, each area can only have one category, the relationship I was able to do , the problem is at the time of displaying, I wanted to display like this:
Categoria1
Area_dela
Outra_area_dela...
Categoria2
Area_dela
Outra_area_dela...
And my loop ended up like this, I tried everything and the maximum I was able to display with the relationship was like this:
CategoryInGeneralhastwoareas,adsandupdates,Othercategorytoo...Icouldnotinsertthecodehere,Iwascuttinghalfofit
Code: link
<?php
include("inc/header.php");
$sqlCategorias = mysqli_query($conexao, "SELECT nomeCategoria, nomeArea FROM categoria INNER JOIN area ON categoria.idCategoria = area.idCategoria");
?>
<div class="container">
<section class="categorias col-md-9">
<?php
while($row = mysqli_fetch_array($sqlCategorias)):
$nomeCategoria = $row['nomeCategoria'];
$nomeArea = utf8_encode($row['nomeArea']);
?>
<article>
<h2><?php echo $nomeCategoria; ?></h2>
<ul>
<li><a href="#"><?php echo $nomeArea;?></a></li>
</ul>
</article>
<?php
endwhile;
?>
</section>
<aside class="widgets col-md-3">
widgets
</aside>
</div>
<?php
include("inc/footer.php");
?>