ok, hopefully you can see what this does... anyway, it doesnt workcan you tell me why? i've checked and checked but cant see why
Please help, thanks.PHP Code:<html><head><title>Creating a table</title></head>
<body>
<?php
if( !$_POST[fields] and !$_POST[db] )
{
$form ="<form action=\"create_table.php\" method=\"post\">";
$form.="How many fields are needed in the new table?";
$form.="<br><input type=\"text\" name=\"fields\">";
$form.="<input type=\"submit\" value=\"Submit\">";
echo($form);
}
else if( !_POST[db] )
{
$form ="<form action=\"create_table.php\" method=\"post\">";
$form.="Database: <input type=\"text\" name=\"db\"><br>";
$form.="Table Name: <input type\"text\" name=\"table\"><br>";
for ($i = 0 ; $i <$_POST[fields]; $i++) {$form.=
"Column Name: <input type=\"text\" name=\"name[$i]\">";
$form.="Type: <select name=\"type[$i]\">";
$form.="<option value=\"char\">char</option>";
$form.="<option value=\"int\">int</option>";
$form.=</select> ";
$form.="Size:<input type=\"text\" name=\"size[$i]\">"; }
$form.="<input type=\"submit\" value=\"Submit\">";
$form.="</form>"; echo($form);
}
else
{
$conn = @mysql_connect("localhost", "shaun", "password")
or die("Err:Conn");
$rs = @mysql_select_db($_POST[db], $conn) or die("Err:Db");
$sql = "create table $_POST[table] (";
for ($i = 0; $i < count($_POST[name]); $i++)
{
$sql .= "$name[$i] $type[$i]";
if(($_POST[type][$i] =="char") or ($_POST[type][$i] =="varchar"))
{
if($_POST[size][$i] != "") ){ $sql.="($_POST[size][$i])"; }
}
if(($i+1) != count($_POST[name]) ){ $sql.=","; }
} $sql .= ")";
echo("SQL COMMAND: $sql <hr>");
$result = mysql_query($sql,$conn) or die("Err:Query");
if ($result)
{ echo("RESULT: table \"$_POST[table]\" has been created"); }
}
?> </body> </html>




can you tell me why? i've checked and checked but cant see why
Reply With Quote