views:

39

answers:

1

I'm working on an image gallery that looks up all of the images that I have uploaded, and allows me to display them 5 at a time on a single page. The problem is, i'm unsure about how to approach this.

I have $_GET['max'], which is supposed to be the top most image to be displayed. $min would be $_GET['max'] - 5. In the event that the user manually enters a number here, I want to set $min to the next number down that's easily divisible by 5, from $REAL_MAX, which is the total number of images that have been uploaded.

How would I go about going through this cycle? I'm relatively new to coding, and I am attending classes on mathematics and logic to help me through some of this stuff.

+2  A: 

If I understand you correctly:

$min = $max - ($max%5) ;

Example: User gives :$max = 53 then $min = 50

The %-sign is the modulus operator giving the remainder of $max divided by 5

Peter Parker