hey there. I am new to php and just out of curiosity I am trying to build an html table using nested while loops. I expect the following code to produce a table, but it is not doing so.
<html>
<table border="1">
<?php
$r=1;
$rows = 5;
$c = 1;
$columns = 5;
while ($r <= $rows) {
echo "<tr>";
while ($c<=$columns) {
echo "<td>d</td>";
$c++;}
echo "</tr>";
$r++;
}
?>
</table>
</html>
I wondered if anyone would know what's the problem with this code. Otherwise, when I substitute for loops in each case of while loops I get tables but with only reduced number of rows and columns. if I ask it to give out 5 rows, for example, it only returns 3.
Remember, I am only interested in using a while loop inside another while loop... just for exercising... any help is much appreciated.