php > Database > check if a table exists

windows

Guest
Hi,

I am writing a php code using a Database. I want it to check if a table exists in a table with such a name, if yes then do "some things", if not create a table with that name and then do "some things"


Thank you in advanceThere are various ways to test this, but to be specific, please let everybody know as much detail as possible.

What database are you using?I'm using mySQl 3.X and I basically want a if statement that does that.

Thanksyou have to query the database and get all the names of all your tables. then you can put those in an array or something and check tha tarray for your name.

mysql_query("SHOW TABLES FROM database_name");

then use
mysql_fetch_array()
to get all the info and do wha tyou like from it.
 
Back
Top