The form
</form>
<br><br><br>
<form action="create_db.php" method="POST">
Enter todays date in this format only: DDMMYYYY<input type=text name="today" size=8><br>
<table border=0 width=25%>
<tr><td align=center><b>Current Table Names:</b></td></tr>
<?
$result = mysql_list_tables("scratch_hnb");
if (!$result) {
print "DB Error, could not list tables\n";
print 'MySQL Error: ' . mysql_error();
}
while ($row = mysql_fetch_row($result)) {
print "<tr><td align=center>$row[0]</td></tr>\n";
}
?>
</table>
<br>
**NOTE** This button creates a table **NOTE**<br>
**NOTE** <font color=red>Look to see if your date already exist</font> **NOTE**<br>
<input type="submit">
</form>
The script
<?
$today = $_POST["today"];
echo "Hello, I'm going to create your database: $today<br>";
if (empty($today)) { echo "You need to add input.<p>"; } else { $result=mysql_query("CREATE TABLE $today ( analyst_id INT( 5 ) UNSIGNED ZEROFILL NOT NULL , name VARCHAR(255), location_id INT( 5 ) UNSIGNED ZEROFILL NOT NULL , schedule_id INT( 5 ) UNSIGNED ZEROFILL NOT NULL , today VARCHAR(1), status_id INT( 5 ) UNSIGNED ZEROFILL NOT NULL , comments VARCHAR(255) )")or die("Create table Error: ".mysql_error()); echo "<p> Your table has been created."; }
?>
The Result
Connected successfully
Hello, I'm going to create your database: 123456
Create table Error: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '123456 ( analyst_id INT( 5 ) UNSIGNED ZEROFILL NOT NULL , name
Lost, Thanks! 🙂