PHP help: Creating dynamic table with html & php using user input?

missytee

New member
I have an assignment:
1. Create a Dynamic table with PHP
1. Start with an HTML form that collects 2 numbers
2. Create a php page that accepts 2 number and creates that sized table
I created my html page:

<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title> Assignment 8 </title>


</head>
<body>

<center>

<form action="assgn8.php" method="post">

Enter the number of rows: <input type=text size=1 name=rows /> <br />
Enter the number of cols: <input type=text size=1 name=cols /> <br />

<input type=submit value="Generate" />

</form>

</center>

</body>
</html>

and then my php page:

<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">

<head>
<title> Assignment 8 </title>
</head>
<body>

<?php
print "<table border=1>";
for ($i = 0; $i < $rows; $i++) {
print "<tr>";
for ($x = 0;$x < $cols; $x++) {
print "<td>";
print "$i,$x";
print "</td>";
}
print "</tr>";
}
print "</table>";
}
?>

</body>
</html>

Am i doing something wrong?! It won't display.
 
Back
Top