RE: How can I organise my data from a total amount into tens?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Using the MOD (%) operator works great for paging and such.  It gives
you the remainder of a division statement:

If ($itemcount % 10 == 0) echo "Itemcount divisible by 10, starting new
page."


Or us the floor() function to determine what the integer is without the
fractional remainder:

$pagenum = floor($itemcount/10) + 1;

Don't forget that if you're using a database that supports the LIMIT
command in SQL, the it works great for paging output!

Good luck!

-TG

> -----Original Message-----
> From: Daniel Anderson [mailto:shadowedmyth@xxxxxxxxxxx] 
> Sent: Thursday, September 16, 2004 7:40 PM
> To: PHP Mailing List
> Subject:  How can I organise my data from a total 
> amount into tens?
> 
> 
> How can I organise my data from a total amount into tens?
> 
> So, say I have a total amount of something like: 50
> 
> I want to organise this so it organises each into 10's
> 
> like this:
> 
> PAGE 1 (01 - 10) | PAGE 2 (11 - 20) | PAGE 3 (21 - 30) | PAGE 
> 4 (31 - 40) | PAGE 5 (41-50) ...
> 
> I basically want to use this function for a guestbook I made,
> 
> I want to organise each post into 10s, so you can click a 
> link and it will select the posts from that group.
> 
> I can get it to select from the group, but what I really want 
> is how to get it do, is how to do the link part:
> 
> "PAGE 1 (01 - 10) | PAGE 2 (11 - 20) | PAGE 3 (21 - 30) | 
> PAGE 4 (31 - 40) | PAGE 5 (41-50) ..."
> 
> So it groups them into 10s so they count up to the total amount...
> 
> If you need me to explain it more please do say :)
> 
> Thanks,
> Dan
> 

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux