![]() |
Paginating An Array
Hello everyone.
I am new to this forum. I'm not sure how I'd paginate an array. I've worked out the $start and $limit. But I'm just not sure how I'd put that into my foreach loop. May I stress that I've already handled displaying the links to the page etc. All I need to do is implement pagination into an array of data. Here's an example of my situation. PHP Code:
I hope you understand my question. Examples of your method of paginating an array in this situation would be appreciated. Thank you. |
This is where you need a for loop and not a for each loop. Then you just use arithmetic modulus to initiate the next page. I use for loops almost exclusively because they're simple, controlable and dependable, both in php and javascript.
|
Quote:
If you could give me an example of such a for loop in my script I would really appreciate it. (I am 14 years of age and sometimes It's good to have an example just to make it "stick"). Thank you. |
If you know the count of the array then you can use a for loop. I happen to have the code for a for loop right in my Clipboard.
PHP Code:
|
Thanks, but how can I use my $limit and $start variables? Because it gets the $_GET['p'] from the url etc
PHP Code:
|
Here's more of my code.
It's getting really stressful now. I've been trying to do this for ages. PHP Code:
|
| All times are GMT +1. The time now is 04:07 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.