Where would you add the CREATE TABLE IF NOT EXIST in this code ?
Add it to your MySQL query, instead of
CREATE TABLE `table_name`;
add in the
IF NOT EXISTS
in the appropriate place.
And can you substitute the OOP code below to procedural so we can learn ?
Don't worry about whether or not you're using OOP. In any case, where you are making a new instance of something, you are using an object even if the rest of your code is not Object Orientated
I'm afraid OOP code got into my code which is procedural the most. This happend because I mix and match codes taken from different youtube tut vids.
Again this is something that you shouldn't worry about. Break your problem down like this:
1) What am I trying to achieve?
2) How am I going to achieve this?
3) Does my PHP script work?
4) If it doesn't work, how do I debug it?
5) If it does work then what do I need to do next?
When you reach step 5, worry about how you've solved your initial problem at a later date. Remember that one can always refactor at some point in the future, when one has a better understanding of what is going on.
OOP is just another way of moving and manipulating data, which is what PHP and all problem-orientated programming languages are all about.