pow(x,y) in php table

I’m supposed to make a php-table where the left column shows a ist from 1-100 and the right column shows the left columns value x².

I’m stuck, my code looks like this, what am I doing wrong?


$rows = 100;
$cols = 2;

echo “



echo "<tr>";
           echo "<td align='left'>",pow($tr,2)."</td>";
echo "</tr>";


echo “



Thanks in advance.

Something like this?


$rows = range(1,100);
$cols = range(1,5);


<?php for ($i = 2; $i < count($cols)+1; $i++) { ?> <?php } ?> <?php foreach ($rows as $row) { ?> <?php foreach ($cols as $col) { ?> <?php } ?> <?php } ?>
x^<?= $i ?>
<?= pow($row, $col) ?>


The end result should look like this.

It does, just change $cols to range(1,2) and remove the headers (the first tr) and you’re set.

Oh I see now, couldn’t exec it before.

Thank you so much!

Sponsor our Newsletter | Privacy Policy | Terms of Service