Search code examples
phphtmlloopstabular

How do I display the output of a "while loop" in a table?


I don't even have an idea of where to start for this. I need to display 100 numbers in a table and would like to use a while loop to do so. Is there a "shortcut" to doing this?


Solution

  • For a table you need some tags table, tr and td. The tr and td are in while loop and the value $i will print inside the td.

    <table>
        <?php
        $i = 1;
        while($i != 101){?>
        <tr><td><?php echo $i++;?></td></tr>
        <?php }?>   
    </table>