Moesian Posted October 29, 2006 Share Posted October 29, 2006 Hi,Im just working though a tutorial book and have stumbled across a bit of a problem whe i use the following code to create a table[code]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><title>Untitled Document</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head><body><?php if (!$_POST['submit']){?> <form method="post" action="<?=$_SERVER['PHP_SELF']?>"> Enter number of rows <input name="rows" type="text" size="4"> and columns <input name="columns" type="text" size="4"> <input type="submit" name="submit" value="Draw Table"> </form><?php}else{?> <table border="1" cellspacing="5" cellpadding="0"><?php//set variables from form input$rows = $_POST['rows'];$columns = $_POST ['columns'];//loop to create rows for ($r = 1; $r <= £rows; $r++){ echo "<tr>"; //loop to crearte columns for ($c = 1; $c <= $columns; $c++) { echo "<td>$nbsp;</tb>\n"; } echo "</tr>\n";}?> </table><?php}?></body></html>[/code]I cant figure out why it doesnt work, the first page works where you can enter the table size but it just doesnt draw the table. Im usingApache 2.0.59 with PHP 5.1.6. I hope someone can point me in the right direction this one puzzles me.Thanks Link to comment https://forums.phpfreaks.com/topic/25462-table-code-problem/ Share on other sites More sharing options...
.josh Posted October 29, 2006 Share Posted October 29, 2006 you made some typos. [code]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><title>Untitled Document</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head><body><?php if (!$_POST['submit']){?> <form method="post" action="<?=$_SERVER['PHP_SELF']?>"> Enter number of rows <input name="rows" type="text" size="4"> and columns <input name="columns" type="text" size="4"> <input type="submit" name="submit" value="Draw Table"> </form><?php}else{?> <table border="1" cellspacing="5" cellpadding="0"><?php//set variables from form input$rows = $_POST['rows'];$columns = $_POST['columns'];//loop to create rows for ($r = 1; $r <= $rows; $r++){ echo "<tr>"; //loop to crearte columns for ($c = 1; $c <= $columns; $c++) { echo "<td> </td>\n"; } echo "</tr>\n";}?> </table><?php}?></body></html>[/code] Link to comment https://forums.phpfreaks.com/topic/25462-table-code-problem/#findComment-116189 Share on other sites More sharing options...
Moesian Posted October 29, 2006 Author Share Posted October 29, 2006 Thanks alot, thought I checked it over properly, sorry to waste your time Link to comment https://forums.phpfreaks.com/topic/25462-table-code-problem/#findComment-116192 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.