Welcome Guest, Not a member yet? Register   Sign In
help pagination
#1

[eluser]Unknown[/eluser]
hello..i am trying to use pagination class
this is the controller..
Code:
<?php
class Exam extends Controller{
function __construct()
{
    parent::controller();
    $this->load->helper('url');
    $this->load->library('pagination');
}
function index()
{        
}
function user()
{
    $page_item         ='2';    
    echo $this->uri->segment(4);
    $this->load->library("pagination");
    $this->load->model("exam_model");
    $config['base_url'] ='http://localhost/demo/index.php/admin/exam/user/';
    $config['total_rows'] = $this->exam_model->count_alluser();
    $config['per_page']=$page_item;
    $config['full_tag_open'] = '<div id="pt">';
    $config['full_tag_close'] = '</div>';
    $this->pagination->initialize($config);    
    $items['data'] = $this->exam_model->get_user($page_item,$this->uri->segment(4));
    $this->load->view("vdemo",$items);

}
}
?&gt;
this is the model..
Code:
&lt;?php
class Exam_model extends Model{
    function __construct()
    {
        parent::Model();
        $this->load->database();
    }
    function get_user($num,$off)
    {
        $this->db->limit($num,$off);
        $query=$this->db->get('user');
        return $query->result_array();
    }
    function count_alluser()
    {
        return $this->db->count_all("user");
    }
    
}
?&gt;
this is the view..
Code:
<table width="413" border="1">
  <tr>
    <td width="36">ID</td>
    <td width="201">Username</td>
    <td width="154">Password</td>
  </tr>
  &lt;?php
  $id=1;
  foreach($data as $item)
  {
  echo "<tr>";
  
  echo "<td>".$id."</td>";
  echo "<td>".$item['username'].'</td>';
  
  echo "<td>".$item['password']."</td>";
  echo "</tr>";
  $id++;
  }
  ?&gt;
</table>

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

i new folder admin ,and move file exam.php in folder admin
error link 1 2 3 > Last. no bold while nick 2 or 3
help please!
#2

[eluser]SpooF[/eluser]
Code:
$config['uri_segment'] = 4;

You need to change the default uri_segment other wise the pagination class doesn't know where it is.
#3

[eluser]Unknown[/eluser]
Thank you very much




Theme © iAndrew 2016 - Forum software by © MyBB