Page 1 of 1

db creation question

Posted: Wed Feb 04, 2004 8:09 pm
by cto1mac
I am really new at PHP so forgive me if this is really simple.

I am able to add/remove/return records from my MySQL db. Now what I want to do is, on start of the page check if the table exists if it doesn't create it then continue on with the rest of the page. I know it is an if-then-else loop but I am still having problems figuring it out.

Thanks

Posted: Wed Feb 04, 2004 8:53 pm
by DuFF

Code: Select all

CREATE TABLE IF NOT EXISTS table_name
(
blah blah blah
);

Posted: Thu Feb 05, 2004 4:30 am
by cto1mac
I am aware of that I am trying to get the loop functionality worked out. How do I check if the table exists and if not build it, if so then don't build just finish writing out the page.

Posted: Thu Feb 05, 2004 6:04 am
by Pointybeard
Well what DuFF said would do that. Its only going to create the table if it doesnt exist. If it does, it wont add it, thus catering for your decision step. Either way you will have that table there, ready to be used... I dont understand y this isnt what you want....