<head>
<title>create your database table</title>
</head>
<body>
<h1>schedule your Appointments<h1>
<form method="POST" ACTION="showfielddef.php">
<p> <strong>your name:</strong><br>
<INPUT TYPE="text" NAME="table_name" SIZE=30></p>
<p><strong>number of people:</strong><br>
<INPUT TYPE="text" NAME=num_fields" SIZE=5></p>
<p> <INPUT TYPE="submit" Name="submit" VALUE="go to field names"></p>
</form>
</body>
</html>
//here is my html and my php why does it not go in order, that way it suppose to look
- Code: Select all
<?php
//Validate important input
if((!$_POST[table_name]) || (!$_POST[num_fields]))
{
header("Location: createtable.html");
exit;
}
// begin creating form for display
$form_block="<form method=\"post\" action=\"createtable.php\">
<input type=\"hidden\" name=\"table_name\" value=\"$_POST[table_name]\">
<table border='1' cellspacing=5 cellpadding=5>
<tr>
<th>Field Name</th> <th> Field Type</th> <th> Field Length</th>
<th>Primary Key?</th><th>Auto_increment</th>
</tr>";
//count from 0 until you reach the number of fields
for($i=0; $i < $_POST[num_fields]; $i++)
{
//add to the form one row for each field
$form_block .="
<tr>
<td align=center>
<input type=\"text\" name=\"field_name[]\" size=\"30\"></td>
<td align=center>
<select name=\"field_type[]\">
<option value=\"char\">char</option>
<option value=\"date\">date</option>
<option value=\"float\">float</option>
<option value=\"int\">int</option>
<option value=\"text\">text</option>
<option value=\"varchar\">varchar</option>
</select>
</td>
<td align=center>
<input type=\"text\" name=\"field_length[]\" size=\"5\"></td>
<td align=center>
<input type=\"checkbox\" name=\"primary[]\" value=\"Y\"></td>
<td align=center>
<input type=\"checkbox\" name=\"auto_increment[]\" value=\"Y\"></td>
</tr>";
}
//finish up the form
$form_block .= "
<tr>
<td align=center colspan=3><input type=\"submit\" value=\" Create Table\"></td>
</tr>
</table>
</form>";
?>
<html>
<head> <title> Create A Database Table Step 2 </title> </head>
<style type="text/css">
body {margin: 10px auto; width 800px; text-align: center;}
h1,th {margin: 10px auto; background-color: #00cccc; width: 800px; text-align: center;}
</style>
<body>
<h1> Define fields for <?php echo "$_POST[table_name]"; ?></h1>
<?php echo "$form_block"; ?>
</body>
</html>

