Skip to content Skip to sidebar Skip to footer

How To Count The Arrays From A Result Of A Query?

I have a query that I make using PHP and it returns me all the rows that satisfied the condition that was given, now, I'm wondering if there's a way to count each number of row a r

Solution 1:

This can be done by setting an $increment variable to 1 at the start of the while loop, and incrementing it at the end of the loop.

<?php$increment = 1;
    while($row = mysqli_fetch_row($res2)) {

And then using it like this:

id="imgDG<?phpecho$increment; ?>">

And then incrementing it at the end:

<?php$increment++;
     }
  ?>

Post a Comment for "How To Count The Arrays From A Result Of A Query?"