RESOLVED Problem with while loops
Posted: Mon Dec 18, 2006 7:29 pm
Hello,
I'm trying to make a matrix builder in php. I have got it to work so that a user can specify how many rows and columns in the matrix, and then use that information in the next page to come up with a table, with inputs for each number place in the matrix.
The trouble I am having is showing the matrix that the user just input.
This is the code:
The seems to be where the problem occurs. It only displays the last row, last column's value, but since it's inside a loop, it should show all of them, in their own column and row in the table. Why is it only showing the last value?
If theres any more information you need from me, let me know.
I'm trying to make a matrix builder in php. I have got it to work so that a user can specify how many rows and columns in the matrix, and then use that information in the next page to come up with a table, with inputs for each number place in the matrix.
The trouble I am having is showing the matrix that the user just input.
This is the code:
Code: Select all
<?php
$rows = $_GET['rows'];
$columns = $_GET['columns'];
$i = 1;
$j = 1;
$n = 1;
$k = 1;
while ($k < ($rows + 1)) {
echo "<tr>";
while ($n < ($columns + 1)) {
echo "<td>";
echo $_POST['r'.$i.'c'.$j];
$j++;
$n++;
}
$n = 1;
$i++;
$k++;
}
?>Code: Select all
$_POST['r'.$i.'c'.$j];If theres any more information you need from me, let me know.