system
November 14, 2012, 11:46pm
1
My task is create a PHP script that will create an HTML table with the number of rows and columns specified by the user, with the row and column number inside the cell. Any ideas or suggestions are greatly appreciated!
My HTML code is as follows
[code]
Table Creator
Table Creator
 Number of rows: 
1
2
3
4
5
6
7
 Number of columns: 
1
2
3
4
5
6
7
[/code]
Make sure sure you put this code in a php file
[php]
<?php
if (isset($_GET['submit'])) {
// set variables from form input
$rows = $_GET['rows'];
$columns = $_GET['columns'];
echo "
\n";
// loop to create rows
for ($r = 1; $r <= $rows; $r++) {
echo "\n";
// loop to create columns
for ($c = 1; $c <= $columns;$c++) {
echo "
";
}
echo "
";
}
echo "
";
}
?>
Table Creator
Table Creator
 Number of rows: 
1
2
3
4
5
6
7
 Number of columns: 
1
2
3
4
5
6
7
[/php]
good luck.