Welcome Guest, Not a member yet? Register   Sign In
Help for a simple pagination ??
#1

[eluser]ludo31[/eluser]
Hello ,

I would like to show one page the value of this array and create pagination according to that

in my controller :

Code:
function index(){
    
      
        
        $data['rows']= array('id'=>array(12,13,14,15,16,17,18,19,20,21,23,24,25,15,26,29,27,29,30,31));
        
  $this->load->library('pagination');
  $config['base_url'] = 'http://localhost/CodeIgniter/';
  
  
  
  $config['total_rows'] = count($data['rows']['id']);
  
  
  $config['per_page'] = 5;
  
  
  $config['num_links']=5;  
            
            
            
            $config['full_tag_open']='<div id="pagination">';
            
             $config['full_tag_close']='</div>';
            
             $config['next_link']='>>';
            
              $config['prev_link']='<<';
              
            

   $this->pagination->initialize($config);


  
  
  
  
      
   $this->load->view('essai_grid',$data);
        
        
        
        
      
    

    }

and in my view

Code:
<ul>
       &lt;?php
      
      // 4 colonnes
      //for($j=0;$j<$result;$j++)
      
       $i = 0 ;
       $j=0;
      
      while($j<$result)
      {
      
      
        if($i==0)
      
          {
       ?&gt;      
          <li class="grid_3 alpha" id="ligne">&lt;?php echo $rows['id'][$j];?&gt;</li>
          
          
          &lt;?php
               $i++;
          
          }
          
          
      
        else
       {
      
        if($i==3)
        {
           $i =0;
          
       ?&gt;
             <li class="grid_3 omega" id="ligne">&lt;?php echo $rows['id'][$j];?&gt;</li>
          <div class="clear"></div>
          
      &lt;?php
        
        }
        else
        {
        ?&gt;
         <li class="grid_3" id="ligne">&lt;?php echo $rows['id'][$j];?&gt;</li>
        &lt;?php
             $i++;
        
        }
       ?&gt;
      
        
       &lt;?php
      
      
      }
      
          $j++;
      
      }
      ?&gt;
  
      </ul>  


</div>
<div class="clear"></div>

<div class="grid_12">Navigation</div>


  &lt;?php echo $this->pagination->create_links();?&gt;

so as I can do research I found code in controller about pagination where it is basin on database so he adds :

Code:
$this->pagination->initialize($config);
              
   $data['page']=  $this->db->get('gnr_convenir',  $config['per_page'],  $this->uri->segment(3));
              
              
             $this->load->view('homme_view',$data);

so What can I make instead of

Code:
// gnr_convenir is a table but me I woud just an array
$data['page']=  $this->db->get('gnr_convenir',  $config['per_page'],  $this->uri->segment(3));




Theme © iAndrew 2016 - Forum software by © MyBB