I want to display all entries present in a table in my MySQL database using for loop (I need for loop for some reason, while loop is not an option). Although I can do it properly in while loop I can't seem to manage to do it with for loop.
Here is my while loop code
while ($row = mysqli_fetch_array($query))
{
echo "<p> " . $row['column-name'] . " </p>";
}
How can I convert this to for loop? I mean how to navigate to each rows using for loop's counter variable?
$counter = mysqli_num_rows($result);
for ($i = $counter; $i > 0; $i--)
{
echo ????;
}
How should I echo the column name and use the $i as the row reference?
forloop?ORDER BY {some-field} DESC