I'm having trouble logically perhaps.
Then it's the following:
$secao="select distinct seccao from foto";
$manda= mysqli_query($ligacao, $secao);
$array_sec=array();
while (($recebe= mysqli_fetch_assoc($manda))!=null){
array_push($array_sec, $recebe["seccao"]);
}
$re=count($array_sec);
$sql = "select imagem, seccao from foto order by seccao desc";
$resultado = mysqli_query($ligacao, $sql);
for($i=0; $i<$re; $i++){
echo '<ul>';
while (($registo = mysqli_fetch_assoc($resultado)) != null) {
if($registo["seccao"]==$array_sec[$i]){
echo "<li><a href=\"img/galeria/".$registo["seccao"]."/" . $registo["imagem"] . "\" data-smoothzoom=\"group1\"><img src=\"img/galeria/".$registo["seccao"]."/" . $registo["imagem"] . "\" width='188' height='119'></a></li>";
}
}
echo '</ul>';
}
In the first query I'll get the sections or categories and store them in an array, I count it to know the size of it. Then I make the second query that is to get all the images and their respective sections.
Finally, I cycle through the length of the array that I measured using the count, and then do the while in which it will cycle through all of the images received by the second query. I do a check to see if the for section is the same as the while loop or image section, the problem here is that the first <ul>
does well but then the rest does not.
The goal was to get all the images of each section in a <ul>
different.