pappakaka Posted February 16, 2011 Share Posted February 16, 2011 Ok i have a question about a dynamic website.. What i have is a site that takes content from the MySQL database and load it into the index.php file. And i know how to change the content of the page when i move around in the navigation, e.g when i click on the "HOME" tab, the content for the home page is shown and when i click on "ABOUT", the information about my site is shown and so on.. Now for my question! I want the content too move everyday automaticly. For example, today i type in some content in the MySQL database that i want to be shown on my website for today. But tomorrow i want the content to have been moved to page 2, and the next day page 3 and so on.. So that everyday i can type in new content, and all the old pages get pushed back one page if that makes sense? Sorry but I have no actuall code for this cause i don't know how to start, but i guess you could use dates and "if else" statements to determine when the pages should be moved and not. Example code would be greatly appriciated! And when i say moved between pages, i mean like this: Today: www.mywebsite.com/index.php?pageid=1 - example 2 www.mywebsite.com/index.php?pageid=2 - example 1 www.mywebsite.com/index.php?pageid=3 - empty Tomorrow: www.mywebsite.com/index.php?pageid=1 - example 3 www.mywebsite.com/index.php?pageid=2 - example 2 www.mywebsite.com/index.php?pageid=3 - example 1 Quote Link to comment https://forums.phpfreaks.com/topic/227927-automaticly-move-back-one-page-everyday/ Share on other sites More sharing options...
cgsmith105 Posted February 17, 2011 Share Posted February 17, 2011 The pages would not actually 'move' per se... that would defeat the purpose of a dynamic website. What you are looking for is http://en.wikipedia.org/wiki/Pagination Sudo code would be: Check if pageid is set if pageid is set then pull records 11 through 20 if pageid is not set then pull first 10 records Quote Link to comment https://forums.phpfreaks.com/topic/227927-automaticly-move-back-one-page-everyday/#findComment-1175529 Share on other sites More sharing options...
denno020 Posted February 17, 2011 Share Posted February 17, 2011 Instead of change the page id for each page on successive days, you should give each page it's own page id, which it will keep forever. Then when you query the database to get the pages, sort them in descending order with respect to page id. This will display the most recent page first. I do believe this is the type of thing you're after? Denno Quote Link to comment https://forums.phpfreaks.com/topic/227927-automaticly-move-back-one-page-everyday/#findComment-1175538 Share on other sites More sharing options...
pappakaka Posted February 17, 2011 Author Share Posted February 17, 2011 The pages would not actually 'move' per se... that would defeat the purpose of a dynamic website. What you are looking for is http://en.wikipedia.org/wiki/Pagination Sudo code would be: Check if pageid is set if pageid is set then pull records 11 through 20 if pageid is not set then pull first 10 records Thank you! Pagination was exactly what i needed, followed this guide (http://www.phpfreaks.com/tutorial/basic-pagination) and solved it! Quote Link to comment https://forums.phpfreaks.com/topic/227927-automaticly-move-back-one-page-everyday/#findComment-1175695 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.