View Single Post
Old 06-26-2012, 03:27 PM   PM User | #1
JordanMRichards
New to the CF scene

 
Join Date: Jun 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
JordanMRichards is an unknown quantity at this point
Exclamation 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:

    
if($got_item_run mysql_query($get_items_q)){
            if(
$item_data mysql_fetch_assoc($got_item_run)) {
            
$item_list $item_data['catalog_items'];
            
$items2 explode(',',$item_list);
            
$hasItem false;
    
                  foreach(
$items as $curr_item) {

                
$curr_items explode('&'$curr_item);
                
$array_length count($curr_items);
                    if(
$array_length>=2) { 
I've made a pagination with mySQL because the "LIMIT" handled a lot of it. But you can't simply put "LIMIT $start, $limit" in a foreach loop.

I hope you understand my question.

Examples of your method of paginating an array in this situation would be appreciated.

Thank you.

Last edited by JordanMRichards; 06-26-2012 at 04:03 PM..
JordanMRichards is offline   Reply With Quote