I am trying to insert user input into a php table. For example if I define a 2x3 table (2 rows and three columns) from a previous page, an input screen displays with 6 inputs for you to fill in whatever you would like to. The 6 content variables are then inserted into a table. I believe an array and possibly a foreach loop may be necessary. However, I am not sure how to get the user input content to carry over to the next page and inserted into a table properly. I also trying to get it into a list, but I assume if the table problem can be solved, it should be the same for the lists. Any help would be greatly appreciated.
//Page where defined inputs are displayed
$row = (isset($_POST['rows']) ? $_POST['rows'] : null);
$col = (isset($_POST['columns']) ? $_POST['columns'] : null);
$list = (isset($_POST['listitems']) ? $_POST['listitems'] : null);
$list2 = (isset($_POST['listitems2']) ? $_POST['listitems2'] : null);
array('[content[]');//Not sure if array should be here or on next page
$y = $list;
$z = $list2;
$x = $row * $col;
for ($i = 1; $i <= $x; $i++) {
echo "$i<input type='text' name='content[]' required> <br>";
}
for ($t = 1; $t <= $y; $t++) {
echo "$t<input type='text' name='content[]' required> <br>";
}
for ($s = 1; $s <= $z; $s++) {
echo "$s<input type='text' name='content[]' required> <br>";
}
echo "<input type='submit' name='submit2' value='Submit'/>
<input type='hidden' name='method' value='post' />
<input type='hidden' name='unorderedinput' value='$list' />
<input type='hidden' name='orderedinput' value='$list2' />
<input type='hidden' name='rowsinput' value='$row' />
<input type='hidden' name='columnsinput' value='$col' />
<input type='hidden' name='cont' value='content[]' />";
echo "</form>";
//page where the table is displayed.
$trow = $_POST['rowsinput'];
$tcol = $_POST['columnsinput'];
$ulist = $_POST['unorderedinput'];
$olist = $_POST['orderedinput'];
$tcontent = $_POST['cont'];
echo "<table border='1'>";
for ($tr = 1; $tr <= $trow; $tr++) {
echo "<tr>";
for ($td = 1; $td <= $tcol; $td++) {
echo "<td align='center'>". "$tcontent". "</td>";//I'm not sure if this is correct
}
echo "</tr>";
}
echo "</table>";