Quote:
Originally Posted by samatair
Hi dlite922,
First i am thankful to you for providing me with two types of solution.
The first one using RAND mysql option, it surely selects listings randomly. But when you use it in pagination each time it will selects listings randomly. i.e. when the user clicks on the 2nd page it will infact select 10 random listings, so the user will not be viewing the next 10 listings, but randomly picked listings. that shouldn't happen.
If the pagination isn't there this would be the simple and perfect solution.
The second ofcourse impressed me, using a text file to store the page number and increment it as each day progress and when all the pages are shown, start over again.
In this solution I have only one problem. When the user clicks the listings page, by default it is on the first page. As with the solution on the 3rd day, the user will be landing on the 3rd page, but I need to show them that they are infact on the 1st page. And ofcourse we know that we are showing the 3rd page today and 4th tomorrow, but the user shouldn't.
If there is a way to get around this, then this should work as breeze for me. Meanwhile, I will try making this work for me and if I get it I will post the info..
Thank you very much for clearly explaining the process.
Samatair
Ok, this is a challenge but I think we don't really /need/ to be on page one, just pretend it's page one right?
so I would take the value of the page for a particular day (let's say for example day 3 thus page 3) and subtract it from itself and add one (3-3+1) when displaying it for the user.
formula:
current page number - day off set + 1 = viewable page number.
I'm writing this as I go so let's check to see if it works.
The user then presses the "next page" button and I think the following two things should happen according to that formula:
1. In the SQL page 4 is shown, because as far as the application is concerned you were on page 3.
2. In the display, your formula's values would be 4-3+1 = 2. Thus the user see that he's on page 2 (when he's actually on page 4)
Question is, what happens when you go the end. Let's say there is a total of 10 pages 10-3+1 would put you at page 8. User viewed actual pages 3 through 10 which equals displayed page numbers 1 through 8. so how does he view page 1 and 2 (which to the user should display page 9 and 10).
Your application code should have a rotational pagination (meaning whenever you reach the last page, it automatically goes back to page one). so now you have these values to work with to get page 9.
3 = the day/page offset
1 = the true page number
putting this in our original formula would rend 1-3+1 = -1. AHA!!
Here's the solution. Whenever this calculated page number the user sees is less than 1 ADD the total number of pages to it. In this case -1 + 10 = 9. Voila!
So on for page Ten: 2-3+1= 0 + 10 = 10
I just thought of this on-the-fly. Does anybody see a fault in it?
Dan