Need to do a nested Do... While loop that shows number of rows and columns based on user input. User types in number of rows and columns in HTML form and it gets processed in the PHP page which I am stuck on. $row and $column are brought in correctly using POST method in PHP, its the do while loop I am stuck on.
What the code should look like
CODE:
<?php
$c=1;
$d=1;
do
{
do{
echo 'loc(r'.($c).',c'.($d).');';
$c ;
} while ($c <= $column);
echo PHP_EOL;
$d ;
$c = 1;
}while ($d <= $row)
?>
CodePudding user response:
Try this:
$column = 4;
$row = 3;
$c = 1;
$r = 1;
do
{
do {
echo 'loc(r'.($r).',c'.($c).');';
$c ;
} while ($c <= $column);
echo PHP_EOL;
$r ;
$c = 1; // important: reset col counter!
} while ($r <= $row);