i'm trying to display a while loop depending on the parameters in my for loop. for example, my for loop says to loop through 5 times, the data inside while loop should also be displayed 5 times. however, when i tested my code, the data inside while loop only displays once. i'm not sure if i did the iteration correctly. here is a snippet of my nested loop.
for($i=0; $i<$count; $i++){
echo "COUNT: ".$i."<br>";
while($data=mysqli_fetch_array($res)) {
echo "INSIDE WHILE".$i."<br>";
}
}
so if my $count = 3, the output of this code is
0
INSIDE WHILE0
INSIDE WHILE0
INSIDE WHILE0
INSIDE WHILE0
INSIDE WHILE0
INSIDE WHILE0
INSIDE WHILE0
1
2
and what i want is for "INSIDE WHILE" to also be displayed between 1 and 2.
mysqli_query()code?whiledepends on the results of your query. If there are no more results to fetch, the while will not run again, regardless of how many times theforis run.whileloop is ended in the first iteration. as it fetch all records in a single-shot. that's why 1 and 2 are having blank