Basically I'm creating and implementing a dynamic website as part of my uni final year project but i am a beginner in php so need some help.
First, I'm not entirely sure about how i should go about creating the database, tables and inserting data. I don't mean in terms of the commands as i know quite a bit of sql but i am unsure of where to use the commands. Currently i have all of the in one php file and then require that file once when the website runs- is this a good way?
Each time the site runs it drops the database first, and then does all of the commands again to avoid duplicate values; the problem i can see with this is that when i then insert new data into the database via forms on the site and then exit and rerun the site that data will be gone as the database has been dropped and only the data inserted in the scripts will be there. Is there a simple way to combat this as i am not sure?
Secondly, instead of connecting to mysql using the standard mysql commands e.g. mysql_connect(connection info);, i am using pdos.
As you know from above, i want to create everything within the file including the database, is it possible to create the actual database in pdos? would it just be
$dbh->exec("CREATE DATABASE $db... ?
Also, is there a pdo command equivalent to mysql_select_db($db);? or will the database i would have just created be automatically selected?
All help is appreciated, thanks.