A Table Generator!


I’m trying to make a table generator, so my “client” can easily add a table to his website if he wishes.

Here’s the code I have so far:


	<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
	<meta name="generator" content="Table Creator">
	<title>Table Creator</title>

<body bgcolor="#ffffff">
	<form action="TableCreator.php" method="post" name="FormName">
		<i><font size="1">*=In Pixels</font></i>
		Number of Rows: <input type="text" name="rownum" size="2" maxlength="2" border="0" value="<? echo($_POST[rownum]);?>">  Number of Columns: <input value="<? echo($_POST[colnum]);?>"type="text" name="colnum" size="2" maxlength="2" border="0"></p>
		<p>Table Width*:  <input type="text"value="<? echo($_POST[tabwidth]);?>" name="tabwidth" size="3" maxlength="3" border="0"> Table Height*: <input type="text" name="tabheight" value="<? echo($_POST[tabheight]);?>"size="3" maxlength="3" border="0"></p>
		<p>Border Width*: <input value="<? echo($_POST[border]);?>"type="text" name="border" size="2" maxlength="2" border="0"> Space Between Cells*: <input type="text" value="<? echo($_POST[cellspace]);?>" name="cellspace" size="2" maxlength="2" border="0"> Cell Padding*: <input type="text" value="<? echo($_POST[cellpad]);?>"name="cellpad" size="2" maxlength="2" border="0"> Alignment: <select name="align" value="<? echo($_POST[align]);?>"size="1">
				<option value="Center">Center</option>
				<option value="Left">Left</option>
				<option value="Right">Right</option>
			</select><br />
> <? if ($_POST['rownum'] != "") {

for( $e=0; $e<$_POST[‘rownum’]; $e++)
{ $row[$e] = “$e”; }
foreach($row as $tabledata) { if ($_POST[‘colnum’] != “”) {

for( $i=0; $i<$_POST[‘colnum’]; $i++)
{ $column[$i] = “$i”; }
foreach($column as $tabdata) { $finish = “Row$tabledata”; $finish .= “Col$tabdata”; echo(""); }
else {
else {


<table <? echo("width=$_POST[tabwidth] height=$_POST[tabheight] cellpadding=$_POST[cellpad] cellspacing=$_POST[cellspace] border=$_POST[border]align=$_POST[align]"); ?>> <? if ($_POST['rownum'] != "") { for( $e=0; $e<$_POST['rownum']; $e++) { $row[$e] = "Row $e"; } foreach($row as $tabledata) { if ($_POST['colnum'] != "") { echo(""); for( $i=0; $i<$_POST['colnum']; $i++) { $column[$i] = "Table Data #$i"; } foreach($column as $tabdata) { echo("$tabledata, $tabdata "); } } else { echo("
"); echo("");} } } else { echo("
"); } ?>

You can view it here

I thought I would be able to just replace the input box code with $_POST variables, but I’m having trouble generating the input names, in order to echo the user’s input! (if that makes any sense)

Basically I want to replace echo("<td><input type="text" name="$finish" size="24" border="0" value="$finish"></td>"); }
with echo("<td> $_POST[$finish]</td>"); } but unfortunately it doesn’t seem to let me use a variable inside there.

I probably confused someone. If you have any suggestions, please let me know.


Try this instead:

echo("<td> ".$_POST[$finish]."</td>"); }


Thanks for trying, that didn’t work.


You might want to verify the source your form output generates. There might simply be an input field that has a name you wouldn’t expect.