Forum Moderators: coopster

Message Too Old, No Replies

PHP and MySQL Tables

         

branmh

5:16 pm on Jun 14, 2005 (gmt 0)

10+ Year Member



This is away to create a php code that checks for a table if not there then creates that table?

dreamcatcher

5:21 pm on Jun 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



$query = mysql_query("CREATE TABLE IF NOT EXISTS table");

if ($query)
{
Table OK
}
else
{
Table Already Exists
}

branmh

5:35 pm on Jun 14, 2005 (gmt 0)

10+ Year Member



Just replace table ok with the actual table command to create that table or ..?

mcibor

6:04 pm on Jun 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No, put it into the query:

CREATE TABLE IF NOT EXISTS your_table_name (id INT NOT NULL auto_increment, bla VARCHAR(50), PRIMARY KEY(id));

Best regards
Michal CIbor