Table-Creation Script : Table Create : MySQL Database PHP Source Code


PHP Source Code » MySQL Database » Table Create »

 

Table-Creation Script




<?
$db_name = "navioo";

$connection = @mysql_connect("mysql153.secureserver.net""navioo""password"or die(mysql_error());
$db = @mysql_select_db($db_name, $connectionor die(mysql_error());

$columnNames = array("col1","col2","col3");
$columnTypes = array("int","Date","double");

$sql = "CREATE TABLE MyTable (";
for ($i = 0; $i < count($columnNames); $i++) {
     $sql .= $columnNames[$i]." ".$columnTypes[$i]", ";

}
$sql = substr($sql, 0, -2);
$sql .= ")";

echo($sql);

$result = mysql_query($sql,$connectionor die(mysql_error());

if ($result) {
     $msg = "<P>MyTable has been created!</P>";
     
     echo($msg);
}
?>

           
       



HTML code for linking to this page:

Follow Navioo On Twitter

PHP Source Code

 Navioo MySQL Database
» Table Create