RE: [PHP-WIN] How can I organise my data from a total amount into tens?
| From: | Gryffyn, Trevor | Date: | Fri, 17 Sep 2004 13:24:59 +0000 |
| Subject: | RE: [PHP-WIN] How can I organise my data from a total amount into tens? | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-24590@lists.php.net to get a copy of this message | ||
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@hotmail.com]
> Sent: Thursday, September 16, 2004 7:40 PM
> To: PHP Mailing List
> Subject: [PHP-WIN] 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
>