tags:

views:

56

answers:

1

Hello all!

Well I have unusual question I think. I am making a web site and the products must be shown as a line I will past a link for better understanding.

http://partyclub.mdkbg.com/products_carbonated_mix.html

Clicking the bottle in the right will change the products to the next. But if you keep clicking will see that when the end of DB rows is near the the small 3 bottles in the left are disappearing. So I am asking is there a way tom make them start over from ID 1 after the last DB query.

Thank you very much.

A: 

Basically you'd have to do 2 queries, possibly 3. One to get the total number of bottles that can be displayed, and another query to retrieve the actual displayable bottles. After that it's a simple check to see if you're getting close to the 'end' of the available data, after which you can loop around to return to the front end.

Let's say you have 10 bottles to be displayed, and are showing 3 at a time:

First hit: show bottles #1,2,3 Second hit: show bottles #4,5,6 Third hit: show bottles #7,8,9 Fourth hit: show bottles #10,1,2 <--the important bit.

In pseudo code, you'd have something like:

query('select bottles to display LIMIT 3');
while($bottle = query_fetch()) {
   if ($rowID >= $total_bottles) {
        restart query at #1
   } else {
        display bottle info
   }
}
Marc B