Hi All,
This is my first post into this forum, let me describe my problem, actually i want to create a table with condition checks, eg if the table is already exit into the database i will get the error , if the table doesnt exit into the database then the table is created and the message will be display,
table human2 is already exit into the database sample, but how could i check if table exits into the database.
<html>
<body bgcolor="lavender">
<?php
//Connect to our localhost using username and password
$con = mysql_connect("localhost","root","");
//Checking connection query
if (!$con)
{
die('Could not connect Database Server : ' .mysql_error());
}
$database=sample;
$check=mysql_select_db("$database",$con);
$table=human2;
if (!$check)
{
die('cant select the database : ' .mysql_error());
}
elseif($check==1)
{
$maketab="CREATE TABLE $table(FirstName varchar(15),LastName varchar(15),Age int)";
//Execute the query
mysql_query($maketab,$con);
echo "tables $table is created ";
}
elseif($maketab==0)
{
echo "Cant create a table ".mysql_error();
}
//Close the my sql connection
mysql_close($con);
?>

