สร้างตาราง Database ด้วย PHP

รูปแบบคำสั่ง

Create Table if not exists tableName(fieldName1 Type(value),fieldName2 Type(value),Primary Key(fieldName) ) ENGINE=MyISAM DEFAULT CHARSET=utf8;

ตัวอย่าง

$conn = “Create Table if not exists tb_guestdata(name Varchar(50),email Varchar(100),comment Longtext,date Datetime,ip Varchar(40),Primary Key(email)) ENGINE=MyISAM DEFAULT CHARSET=utf8”;
$qry=mysql_query($conn);
if($qry){
echo “create table successfull. <br>”;
}else{
echo “not create <br>”;
}

new topic

  This text.
    This text.