PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<form name="form1" method="post"
action="maketable.php">
<label>
Table Name </label>
<p>
<input name="tbname" type="text" id="tbname">
</p>
<p> </p>
<table border="1" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF" bgcolor="#CCCCCC">
<tr>
<td width="30">Field</td>
<td width="144"><div align="center">Name</div></td>
<td width="144"><div align="center">Length</div></td>
<td width="201"><div align="center">Attributes</div></td>
<td width="80">Null</td>
<td width="81">Default</td>
<td width="81">Extra</td>
</tr>
<tr>
<td>1</td>
<td><input name="field1" type="text" id="field1"></td>
<td><input name="length1" type="text" id="length1"></td>
<td><select style="font-size: 70%;" name="attribute1" id="field_0_5">
<option value="" selected="selected"></option>
<option value="UNSIGNED">UNSIGNED</option>
<option value="UNSIGNED ZEROFILL">UNSIGNED ZEROFILL</option>
<option value="ON UPDATE CURRENT_TIMESTAMP">ON UPDATE CURRENT_TIMESTAMP</option>
</select></td>
<td><select name="null1" id="field_0_6">
<option value="NOT NULL" selected="selected" >not null</option>
<option value="">null</option>
</select></td>
<td><input id="field_0_7" type="text" name="default1" size="12" value="" class="textfield" /></td>
<td><select name="extra1" id="field_0_8">
<option value=""></option>
<option value="AUTO_INCREMENT">auto_increment</option>
</select></td>
</tr>
</table>
<p>
<label>
<input type="submit" name="Submit" value="Submit">
</label>
</p>
</form>
///here is my php that gets the values of these and then creates a table
<?
//conection stuff
$table=$_POST['tbname'];
$field1=$_POST['field1'];
$field2=$_POST['field2'];
$field3=$_POST['field3'];
$length1=$_POST['$length1'];
$length2=$_POST['$length2'];
$length3=$_POST['$length3'];
$attribute1=$_POST['$attribute1'];
$attribute2=$_POST['$attribute2'];
$attribute3=$_POST['$attribute3'];
$maketable="CREATE TABLE $table(
$field1 varchar($length1) $attribute1 NOT NULL default '',
$field2 varchar($length2) $attribute2 NOT NULL default '',
$field3 varchar($length3) $attribute3 NOT NULL default '')";
//so this would be if you had a 3 field table i would need to make it so this would make it for as many rows you have chosen sorry if i have not explained it well
$domaketable=mysql_query($maketable);
if ($domaketable) {
echo "Created $tbname";
}
else
{
echo "Error $tbname";
}
?>
thanks reece
Last edited by reecec on Wed Jul 26, 2006 12:52 pm, edited 2 times in total.
would it be something like this
where it would give me 5 rows where i have $counter <= 5 this would be a variable so a number to be chosen but for the sake of the question this should give me 5 rows of textboxes but the loop doesnt like having all the text box stuff around the $end and just wants the $end as i get this error
Parse error: parse error, unexpected T_STRING, expecting ',' or ';'
I relilaised what was wrong your code worked but was not needed as you said
i think this was the problem could you just confirm that im right becuase i have noticed this alot when putting text boxes in an echo
is it because you open the echo " but when you get to input name=" <name> " it sees the other speech marks and ends the echo so i opened it with '
and thanks you have replied alot to my posts and have helped me your a good mod