Drongo_III Posted March 19, 2011 Share Posted March 19, 2011 Hi Guys Just learning php. I want to write my own simple cms to get to grips with how things work (not necessarily to use as i realise there are millions of open source cmses available that are much more secure and clever). I'm ok with capturing and storing data in a database and i know the rudmiments of php so far. What i'm not so clear about, and what's missing from all the tutorials i've read, is how you load the data stored in a database relating to a specific page. All examples i've seen simply access the database and dump all the content into a page. So lets say i stored some body text in a database table with a unique key of 4. I then click on a link somewhere in the website, lets say it's www.mysite.com/4 (lets assume i've done the clever stuff with .htaccess) What is the best way of loading that specific page content? Do you access the header url and strip out the end part? Then compare that to your database ? Or is there a better way? Sorry if this is vague i'm just after a brief explanation and i'll go do the leg work to find out how to do it Thank you! Quote Link to comment https://forums.phpfreaks.com/topic/231113-newbie-cms-page-question/ Share on other sites More sharing options...
QuickOldCar Posted March 19, 2011 Share Posted March 19, 2011 That unique key of 4 you speak of could be a GET value, doing an if/else statement of the GET could determine what content is displayed on the same page by using includes or writing the different mysql queries inside the if/else statement. Quote Link to comment https://forums.phpfreaks.com/topic/231113-newbie-cms-page-question/#findComment-1189612 Share on other sites More sharing options...
Drongo_III Posted March 19, 2011 Author Share Posted March 19, 2011 Hi Quick Thanks for your post. I get what you've said but that just leaves me with the mystery of how you tell the script what look for. So if I've clicked on a link for www.mysite.com/4, then how do i tell the script that the user has clicked on a link and wants to visit page 4? Sorry if i'm being slow and missing something obvious :/ That unique key of 4 you speak of could be a GET value, doing an if/else statement of the GET could determine what content is displayed on the same page by using includes or writing the different mysql queries inside the if/else statement. Quote Link to comment https://forums.phpfreaks.com/topic/231113-newbie-cms-page-question/#findComment-1189617 Share on other sites More sharing options...
QuickOldCar Posted March 19, 2011 Share Posted March 19, 2011 Let me give you a few demo of codes I wrote up and can look at them a bit. A simple navigation http://get.blogdns.com/navigation/ This one creates single posts http://get.blogdns.com/dynaindex/post-variable.php Here's some pagination ones. http://get.blogdns.com/paginate/ http://get.blogdns.com/dynaindex/paginate.php A post in the forum parsing urls http://www.phpfreaks.com/forums/index.php?topic=319755.0 This is the function code to find path one http://www.phpfreaks.com/forums/index.php?topic=319755.msg1506929#msg1506929 If any more questions feel free to ask. Quote Link to comment https://forums.phpfreaks.com/topic/231113-newbie-cms-page-question/#findComment-1189642 Share on other sites More sharing options...
Drongo_III Posted March 19, 2011 Author Share Posted March 19, 2011 Thanks for all the info Quick! I think I have a much better idea of how it's done now. Looks to be a case of appending IDs to each link via query strings and i suppose i can then use that info to dynamically load specific content from the database. Going to have a fiddle and will let you know if i have any questions. Thanks loads for all the links and info! Let me give you a few demo of codes I wrote up and can look at them a bit. A simple navigation http://get.blogdns.com/navigation/ This one creates single posts http://get.blogdns.com/dynaindex/post-variable.php Here's some pagination ones. http://get.blogdns.com/paginate/ http://get.blogdns.com/dynaindex/paginate.php A post in the forum parsing urls http://www.phpfreaks.com/forums/index.php?topic=319755.0 This is the function code to find path one http://www.phpfreaks.com/forums/index.php?topic=319755.msg1506929#msg1506929 If any more questions feel free to ask. Quote Link to comment https://forums.phpfreaks.com/topic/231113-newbie-cms-page-question/#findComment-1189706 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.