Hi all, this one’s been bothering me for a while and I think would really streamline my php development.
Basically I see loads of sites with the vague code “index.php?page=home” where the “page=home” determines the content of the page, with everything else being an outside template (probably stored in index.php).
My thinking was it was a conditional statement basically saying, if the page url contains the word home, then run this script etc… but I can’t figure it out!?
Should be simple for some of you, just looking for the best practice on this one and a tutorial
The $_GET[‘page’] variable can be used to then query a database or load a flatfile page
$page = isset($_GET['page']) ? $_GET['page'] : 'default';
// if the page=home variable is set then store it in a simple variable
$sql = mysql_query("select content from dbtable where pagename = '". mysql_real_escape_string($page) ."'");
// query the database and get the information
then use mysql_fetch_assoc($sql); to assign the database info and echo it onto the page