Hi,
I’ve been playing around with a page I want to create using php and mysql data.
My goal is to have a page url look like http://somesite.com/?page=pagename.
I also want when the page is loaded that “pagename” relates to a mysql table entry. So that I can then echo the page title and content from my mysql database.
This is the code that I have tried to piece together using code that I had from a different project:
<?php include('dbconnect.php'); $page = $_GET['pagename']; $dispage = mysql_query("SELECT page FROM pages WHERE page = '$page'"); $default = mysql_query("SELECT page FROM pages WHERE page = home"); if(mysql_num_rows($dispage) !== 0) { include $dispage; } elseif(mysql_num_rows($default)) { include $default; } else { echo 'The page your requested does not exist.'; } ?>I’m not quite sure how else to explain what I’m trying to do, hopefully someone gets the idea.
-Thanks
Sean