db creation question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
cto1mac
Forum Commoner
Posts: 54
Joined: Tue Jan 27, 2004 6:11 am
Location: Virginia Beach, VA

db creation question

Post 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
User avatar
DuFF
Forum Contributor
Posts: 495
Joined: Tue Jun 24, 2003 7:49 pm
Location: USA

Post by DuFF »

Code: Select all

CREATE TABLE IF NOT EXISTS table_name
(
blah blah blah
);
User avatar
cto1mac
Forum Commoner
Posts: 54
Joined: Tue Jan 27, 2004 6:11 am
Location: Virginia Beach, VA

Post 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.
User avatar
Pointybeard
Forum Commoner
Posts: 71
Joined: Wed Sep 03, 2003 7:23 pm
Location: Brisbane, AUS
Contact:

Post 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....
Post Reply