• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pagination question : the data change, not the link.

#1
[eluser]sloth[/eluser]
hi, i have a problem with paging in codeigniter.

here my controller in function index:
Code:
$data['flash_message'] = '';
$data['page_title'] = 'List of Patient';
            
//load class Pagination</pre>  
$this->load->library('pagination');  
$config['base_url'] = base_url().'index.php/P/p/index';  
$config['total_rows'] = $this->db->count_all('p_d');  
$config['per_page'] = '15';  
$config['num_links'] = '10';
        
$config['full_tag_open'] = '<p>';
$config['full_tag_close'] = '</p>';
        
$this->pagination->initialize($config);  
$dati['number'] = $this->uri->segment(4);
        
$data['data_list'] =  $this->Patient_model->getData_page($config['per_page'], $this->uri->segment(4));  
        
$data['paging'] = $this->pagination->create_links();  
$this->load->view('P/p/form_view',$data);

here my model :

Code:
function getData_page($num,$offset)
    {
        $query = $this->db->get('p_d', $num,$offset);  
        return $query->result();  
    }

here my view :

Code:
<h2>&lt;?php echo $page_title;?&gt;</h2>
<p>&lt;?php echo $flash_message;?&gt;</p>

    <table width="500" class="stripe" >
    <tbody>
    <tr>
        <th class="IdColumn" >&lt;?php echo 'RM';?&gt;</th>
        <th class="IdColumn" >&lt;?php echo 'NP';?&gt;</th>
        <th></th>
    </tr>
    &lt;?php foreach($data_list as $data): ?&gt;
    <tr>
        <td>&lt;?php echo $data->pd_nr;?&gt;</td>
        <td>&lt;?php echo $data->pd_n;?&gt;</td>
        <td><a href="&lt;?php echo site_url(">pd_nr")?&gt;"
                class="submenu_link_add">detail</a></td>
    </tr>
    &lt;?php endforeach ?&gt;
    </tbody>
       </table>
&lt;?php echo $this->pagination->create_links(); ?&gt;
    <p>
        <a href="&lt;?php echo site_url('P/p/add')?&gt;" class="submenu_link_add">Reg</a>
    </p>
    
<hr />

here my problem :
i have success to show the data and the links on screen. (it's running well)
When i click to the next page (any page) on the links, the data change to the next page data, but the links not change, it still show an first page...

i don't know where should i check..
fyi, i modif my script from
here

when i running the script sample from that page, it running well...

........

when i try another paging sample like this tutorial, this tutorial, and this tutorial

it come a same problem before... the data show, but the links stay...

-sorry for my english-
many people say it's a simple problem, but i can't solve it yet...

#2
[eluser]umefarooq[/eluser]
Hi put in you config
Code:
$config['uri_segment'] = 4;

The pagination function automatically determines which segment of your URI contains the page number. If you need something different you can specify it.

check user guide also
http://ellislab.com/codeigniter/user-gui...ation.html

#3
[eluser]sloth[/eluser]
it's running well...

thx umefarooq..





*oh.. malu aku...*


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.