note 111115 added to function.mysql-create-db
| From: | davood2003arabi at yahoo dot com | Date: | Wed, 16 Jan 2013 17:39:56 +0000 |
| Subject: | note 111115 added to function.mysql-create-db | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-193115@lists.php.net to get a copy of this message | ||
Create a Table
The CREATE TABLE statement is used to create a table in MySQL.
Syntax
CREATE TABLE table_name
(
column_name1 data_type,
column_name2 data_type,
column_name3 data_type,
....
)
<?php
$con = mysql_connect("localhost","peter","abc123");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
// Create database
if (mysql_query("CREATE DATABASE my_db",$con))
{
echo "Database created";
}
else
{
echo "Error creating database: " . mysql_error();
}
// Create table
mysql_select_db("my_db", $con);
$sql = "CREATE TABLE Persons
(
FirstName varchar(15),
LastName varchar(15),
Age int
)";
// Execute query
mysql_query($sql,$con);
mysql_close($con);
?>
----
Server IP: 69.147.83.199
Probable Submitter: 85.154.57.133
----
Manual Page -- http://php.net/manual/en/function.mysql-create-db.php
Edit -- https://master.php.net/note/edit/111115
Del: integrated -- https://master.php.net/note/delete/111115/integrated
Del: useless -- https://master.php.net/note/delete/111115/useless
Del: bad code -- https://master.php.net/note/delete/111115/bad+code
Del: spam -- https://master.php.net/note/delete/111115/spam
Del: non-english -- https://master.php.net/note/delete/111115/non-english
Del: in docs -- https://master.php.net/note/delete/111115/in+docs
Del: other reasons-- https://master.php.net/note/delete/111115
Reject -- https://master.php.net/note/reject/111115
Search -- https://master.php.net/manage/user-notes.php