How can i loop in ordered list tage with php while [closed]

The ordered list tag should be outside the loop otherwise you’re making a new list every time you loop through

$x

This should work:

<?php 
    $x = 1; 
    echo "<ol>";
    while($x <= 5) {
    echo "<li>" + $x + "</li>";
    $x++;
 }
 echo "</ol>";
 ?>

Leave a Comment