Last question wasn't received well so I've done more reading and came up with a simple php program that accepts user input for number of rows and columns. A table is generated using nested while loop and I do understand that a 'For' loop is more suited for this and got it working using one. Trying to learn and get better so I want to figure this one out too. I'm getting one row only and no columns. I also want the iteration to produce rows and columns that appear like the example. Kind of frustrated the for loop was much easier to finally figure out.
W,row1,col1; W,row1,col2; W,row1,col3
W,row2,col1; W,row2,col2; W,row2,col3 etc...
php code:
<?php
if(isset($_GET['rows'])) {
$r = 1;
$c = 1;
$rows = 5;
$cols = 6;
while ($r <= $rows) {
echo '<tr>';
while($c <= $cols) {
echo '<td>W, '.'row' .$r.',col'.$c.';</td>';
$c++;
}
echo '</tr>';
$r++;
}
?>
$rowsis always the same number, you need to have something that decrements$rows(and$colsof course) on each iteration of the loop so that eventually it will no longer be >=1. You are also missing a semi-colon on$count++. I hope this helps.