use of $this->uri->segment(3) in codeigniter pagination


This provides you to retrieve information from your URI strings
$this->uri->segment(n); // n=1 for controller, n=2 for method, etc
it will return
$this->uri->segment(1); // controller
$this->uri->segment(2); // action
$this->uri->segment(3); // 1stsegment
$this->uri->segment(4); // 2ndsegment

pagination in codeigniter

view Code

 <?php
$i=1+$this->uri->segment(3);
if(is_array($displaydata))
{
foreach($displaydata as $db) {
?>

custom fileds...

 <?php $i++;  } } ?>

<?php if(empty($displaydata)) { ?>
            <tr>
            <td colspan="7" bgcolor="#F8F8F8">No Records Found .. .... ...</td>
            </tr>
            <?php }  ?>      
</table>  <?php echo $this->pagination->create_links();?></td>



controller code

public function certificatedata()
{
$displaydata = $this->mreminder->listcertificatedata('','') ;

$total_rows = count($displaydata) ;
$config['base_url'] =  base_url().'index.php/welcome/certificatedata/' ;
$config['per_page'] = 10 ;
$config['full_tag_open'] = '<div>' ;
$config['full_tag_close'] = '</div>' ;
$config['first_link'] = 'First' ;
$config['last_link'] = 'Last' ;
$config['use_page_numbers'] = FALSE ;
$config['prev_link'] = '&lt;';
$config['uri_segment'] = 3 ;
$config['num_links'] = 7 ;
$config['cur_tag_open'] = '<b>' ;
$config['cur_tag_close'] = '</b>' ;
$config['total_rows'] = $total_rows ;

$displaydata = $this->mreminder->listcertificatedata($config['per_page'], $this->uri->segment(3)) ;

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

$data = array(  
'displaydata' => $displaydata    
) ;

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


Model COde

function listbillingdata($num, $offset)
{

if($offset!="")
{    
     $que = "select * from billingtbl where deleted=0  LIMIT ".$offset.", ".$num."";
}
else if($num!="")
{
  $que = "select * from billingtbl where deleted=0 LIMIT ".$num."" ;
}
else
   {
$que = "select * from billingtbl where deleted=0" ;
}


$query = $this->db->query($que) ;  
$results = $query->result_array() ;
return $results  ;
}


Collection of Important Dynamic Web Programming languages Ebooks

Hello Geeks! - you know i already have Collection of important Programming languages ebooks, but that is Software + Web App programming ebooks and after posting "How to become Web Programmer complete guide for beginners" many readers requested me to upload Dynamic Web Programming languges ebooks. In this post i've covered "AJAX, ASP.NET, Coldfusion, Perl, PHP, Ruby and Ruby on Rails Ebooks - Free giveaway.

Note : We've compressed Ebooks in ZIP format (99% Virus Free) Mediafire Download Links - Just Click on Ebook name & Download instantly. Thank you


I. AJAX (Asynchronous JavaScript and XML)



II. ASP (Advance Static Pages)



III. Coldfusion



IV. Perl



V. PHP (HyperText Preprocessor)

VI. Ruby


VII. Ruby on Rails



Thank you for reading my post, And if any link is broken feel free to comment and let me know your problem. You can also request any other Programming e-books (We'll upload it Asap!) If you like it please do a share to increase us.