0

Thank you for taking the time to help.

I'm working on an assignment for school, and I know this question seems similar to others on Stack, but it has a small change that makes all the difference.

I need to create a simple PHP webpage that displays a table whose cells are filled with random numbers. Easy enough, however, I cannot use PHP to display any of the table tags. Originally I had this:

<table id="tab1">
<?php
for ($row = 0; $row <= 10; $row++) {
    echo "<tr> \n";
    for ($col = 0; $col < 10; $col++) {
        $r = rand(10,100);
        echo "<td>$r</td> \n";
    }
    echo "</tr>"; 
  }
?>
</table>

This works and has the functionality I need, but it uses PHP to display the table row and table cell tags, and the assignment instructions say not to. So I tried this:

<table id="tab1">
    <?php
    for ($row = 0; $row <= 10; $row++) {  
    ?>
    <tr> 
        <?php 
        for ($col = 0; $col < 10; $col++) {
            $r = rand(10,100);   
        ?>
        <td>
            <?php$r?>
        </td>
        <?php }?>
        </tr>
        <?php}?>
    </tr>

</table>

But of course, it isn't working, so what am I missing? I'd appreciate any advice!

Andrew
  • 35
  • 6

0 Answers0