Create table in MySQL through PHP
In this article I will go to explain about how to create table in MySQL through PHP.
PHP MySQL create table
Table is a collection of rows and columns.
Creating a table
The CREATE TABLE statement is used to create a table in MySQL.
Syntax of creating a table
CREATE TABLE tableName
{
columnName1 datatype,
columnName2 datatype,
...........
}
|
Example of creating a table
<html>
<body>
<?php
$con = mysql_connect("localhost","gupta","sharad");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
else
{
echo "Emp table is created.";
}
mysql_select_db("Mcn_Solution", $con);
$qry = "CREATE TABLE Emp
(
Fname varchar(15),
LastName varchar(15),
Id int
)";
mysql_query($qry,$con);
mysql_close($con);
?>
</body>
</html>
|
Output:
You may also want to read these related articles :here
Ask Your Question
Got a programming related question? You may want to post your question here
Programming Answers here