0
The menu is practically ready, in the last part I am facing a problem with the foreach
, as shown on the right side of the image (the menu on the left is still the mechanical menu).
For the categories, first I will need their id, so far so good. The problem is the foreach
is repeating the ids:
<?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 you’re repeating is this foreach ($p as $key => $value)
, I tried to change the beginning of the loop, but nothing.
Why are you making 2 selects in the same table? takes the menu and the url in the same sql,
– Gilmar Alonso
I did that and it got better. There’s still a point I need to adjust. I can delete the explanation above and put a new version or create another topic?
– Rogério Pancini