we use CREATE TABLE statement to create table in mysql
//sql statement to create table
$sql="CREATE TABLE (column_name1 data_type,
column_name2 data_type,
column_name3 data_type) ";
example:
$con = mysql_connect("localhost","root","root");
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 customers
(
Name varchar(15),
designation varchar(15),
Age int
)";
// Execute query
mysql_query($sql,$con);
?>
0 comments:
Post a Comment