Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/227927-automaticly-move-back-one-page-everyday/
Share on other sites

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

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

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! :D

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.