This is something I've been curious about for awhile, and never got it to work quite right. Now I can admit that I'm not the greatest programmer in the world (I'm a Content guy!), but I do know the basics of PHP, and have created a few websites using the scripting language before.
Now here's the thing, I LOVE database design (and yet I HATE SQL). So along with already having the templates and design completed, I already have the MySQL database created and filled with the information I want to display on the website. Let me explain what I had in mind in setting this up:
I have a "Page" Table, in addition to other tables (not necessary for this part of the CMS though), and the following columns: page_ID, title, content, and url (a page slug)
I have an index.php page with the basic server-side setup I need
I already have the header, footer, config, and functions files created (where I require_once them in)
Now I was thinking about just writing up an SQL query in the body of the index file (This is the only display method I could find after searching for hours through dozens of Custom CMS tutorials):
PHP Code:
<?php
$indexquery = "SELECT content FROM Page";
$indexresult = mysql_query($indexquery, $link) or die(mysql_error());
while($row = mysql_fetch_array($indexresult)){
echo "<div id='webdescription'>" . $row['content'];
echo "</div>";
}
?>
But the problem with this setup is that it retrieves data from every row in the content column, I don't want that. Then I thought about just adding a WHERE page_ID ='some_number' statement, which gives me what I want, but I'd have to create a php file for every single, and that's not good either.
I was trying out some test scripts to add to the file that might somehow change the URL based on page_ID, but I have no idea how to do that. The structure would look something along the lines of this, and I'd just mod_rewrite the url's later (they're not important for the time being):
http://www.site.com/index.php?=1
I also had Wordpress's system in mind when designing this, but couldn't see how they were doing it either.