Welcome Guest, Not a member yet? Register   Sign In
Pagination + URI Routing problem
#1

[eluser]mo2men[/eluser]
hi

this my code

routes.php
Code:
$routes['review/(:any)'] = "review/index/$1";

review.php
Code:
<?php
class review extends Controller{

   function _remap($method)
   {
      if(method_exists($this,$method))
      {
        $this->$method();
      }
      else
      {
        $this->index();
      }
   }

   function  __construct() {
       parent::Controller();
        $this->load->model('review_model');
        $this->load->library('form_validation');
        $this->load->library('pagination');
    }

    function index($offset='')
    {
       $url = $this->uri->segment(2);
       $query = $this->review_model->exist_review($url);
               if($query == FALSE){
                   echo "no";
               }


               else{
                $limit = 3;
                $total = $this->review_model->count_posts($url);
                
                $query = $this->review_model->read($limit,$offset);
                if($query)
                {
                $data['row'] = $query;
                }

                $config['base_url'] = base_url().'review/'.$url;
                $config['total_rows'] = $total;
                $config['per_page'] = $limit;
                $config['num_links'] = 3;
                $config['uri_segment'] = 3;
                
        $this->pagination->initialize($config);

        $data['pag_links'] = $this->pagination->create_links();
                $data['sidebar'] = 'review-sidebar';
                $data['site_content'] = 'review';
                $this->load->view('include/template.php',$data);

               }
    }

    
}
?>


review_model
Code:
<?php
class review_model extends Model{
    function  __construct() {
        parent::Model();
    }
    function exist_review($url){
        $this->db->select('username');
        $this->db->where('username',$url);
        $this->db->from('users');
        $query = $this->db->get();
           if($query->num_rows > 0 ){
                 return TRUE;
             }
             else{
                 return FALSE;
             }
    }

    function count_posts($url,$gpt=''){
                $this->db->where('username',$url);
      
         return $this->db->count_all_results('gpt');
     }

    function read($limit, $offset,$gpt=''){

     ($gpt) ? $this->db->where('gpt' , $gpt) : '';
     $this->db->limit($limit, $offset);
     $this->db->select('*');
     $this->db->from('gpt');
     $this->db->order_by('id','desc');
     $query = $this->db->get();
           if($query->num_rows > 0 ){
                 return $query->result();
             }
             else{
                 return FALSE;
             }

     }
    

}


?>

now i use Pagination and $routes['review/(:any)']

and when go http://localhost/site/review/mo2men/3

mo2men = $url

no get next records(data) from mysql

i don't know problem with mysql (model) or bath

help????????????


Messages In This Thread
Pagination + URI Routing problem - by El Forum - 12-28-2010, 10:37 PM
Pagination + URI Routing problem - by El Forum - 12-29-2010, 12:44 AM
Pagination + URI Routing problem - by El Forum - 12-29-2010, 04:14 AM
Pagination + URI Routing problem - by El Forum - 12-29-2010, 05:06 AM
Pagination + URI Routing problem - by El Forum - 12-29-2010, 08:28 AM
Pagination + URI Routing problem - by El Forum - 01-07-2011, 02:06 AM
Pagination + URI Routing problem - by El Forum - 01-07-2011, 02:23 AM



Theme © iAndrew 2016 - Forum software by © MyBB