The menu is almost ready, in the last part I'm facing a problem with foreach
, as the right side of the image demonstrates (the menu on the left is still the mechanical menu).
Forthecategories,I'llfirstneedtheirid,sofarsogood.Theproblemisforeach
isrepeatingtheids:
<?php$sql_2_a=mysqli_query($config,"SELECT DISTINCT menu FROM recursos ORDER BY menu ASC") or die(mysqli_error($config));
if(@mysqli_num_rows($sql_2_a) <= '0'){
echo "
<div class=\"row\">
<div class=\"col-lg-6\">
<div class=\"alert alert-danger\">
<strong>Erro!</strong> $erro
</div>
</div>
</div>
";
}else{
while($r_sql_2_a = mysqli_fetch_array($sql_2_a)){
$id_menu_sel = $r_sql_2_a[0];
$sql_3 = mysqli_query($config, "SELECT url FROM recursos WHERE menu = '$id_menu_sel'") or die(mysqli_error($config));
if(@mysqli_num_rows($sql_3) <= '0'){
echo "
<div class=\"row\">
<div class=\"col-lg-6\">
<div class=\"alert alert-danger\">
<strong>Erro!</strong> $erro
</div>
</div>
</div>
";
}else{
$p = Array();
while($r_sql_3 = mysqli_fetch_array($sql_3)){
$p[] = $r_sql_3[0];
}
}
foreach ($p as $key => $value) {
if($value==$pagina_link){
echo "<b>".$id_menu_sel."</b>";
}else{
echo $id_menu_sel;
}
}
}
}
?>
What is repeating is this foreach ($p as $key => $value)
, already tried to change the beginning of the loop, but nothing.