Welcome Guest, Not a member yet? Register   Sign In
I have a problem with pagenition pls help
#5

[eluser]Ckirk[/eluser]
You could make use of the form validation library to determine whether $this->uri->segment(3) is actually a number. I've changed your code so try the code below. It's untested but should work.
I haven't accounted for anyone entering a valid page number, which exceeds the number of records in the database. In this scenario your query would return zero results but I'm sure you know how to handle that - at least there's no DB/SQL errors now Smile


Code:
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
All Copyrights reserved.
Programmer information
Name : Fahad Salim Alrahbi
Location: Sultanate of Oman - Muscat
Email : [email protected]
Tel : +968 98985262
*/

class showq extends CI_Controller{
    
    
    function viewv(){
        $this->load->library(array('pagination','form_validation'));   // don't forget to load form_validation lib
        
        $config['base_url'] = 'http://localhost/cic/showq/viewv';
        $config['total_rows'] =$this->db->get('topic')->num_rows();
      
        $config['per_page'] = 4;
        $config['num_links']=5;
        $config['first_link'] = 'Start';
        $config['last_link'] = 'End';
        $config['prev_link'] = 'Back';
        
        // Set the $page to be 0 if the number in the URI is crap
        $page = !$this->form_validation->is_natural($this->uri->segment(3)) ? 0 : $this->uri->segment(3);
    
        
    
        $this->pagination->initialize($config);
      
        $s=$this->db->get('topic',$config['per_page'],$page);
         foreach($s->result() as $datar){
            
            $row[]=$datar;
         }      
        $this->parser->assign('pages',$this->pagination->create_links());
        $this->parser->assign('row',$row);
        $this->parser->parse('showq.tpl');
    }
}
?>


Messages In This Thread
I have a problem with pagenition pls help - by El Forum - 09-17-2012, 11:01 PM
I have a problem with pagenition pls help - by El Forum - 09-18-2012, 12:24 AM
I have a problem with pagenition pls help - by El Forum - 09-18-2012, 12:34 AM
I have a problem with pagenition pls help - by El Forum - 06-19-2013, 06:42 PM
I have a problem with pagenition pls help - by El Forum - 06-22-2013, 04:01 PM
I have a problem with pagenition pls help - by El Forum - 06-23-2013, 07:57 PM
I have a problem with pagenition pls help - by El Forum - 06-24-2013, 01:00 AM
I have a problem with pagenition pls help - by El Forum - 06-24-2013, 08:41 PM
I have a problem with pagenition pls help - by El Forum - 06-24-2013, 10:31 PM



Theme © iAndrew 2016 - Forum software by © MyBB