EllisLab text mark
Advanced Search
2 of 3
2
   
[SOLVED]Pagination Problem!
Posted: 28 January 2010 12:07 AM   [ # 16 ]   [ Rating: 0 ]
Avatar
Joined: 2009-12-16
338 posts

the pagination is giving you an offset instead of a page number…try to change

$offset = ($page-1) * $config['per_page']

to

$offset $page

and let us see what will now happen..

 Signature 

“Anything executable is testable”- debug

 
Posted: 28 January 2010 12:24 AM   [ # 17 ]   [ Rating: 0 ]
Joined: 2010-01-24
100 posts

erhhh..
still the same??!!
any other solutions?
huhu

i have 10 reports..
but it only display 5 of them..

 Signature 

-the Beginner-

 
Posted: 28 January 2010 12:46 AM   [ # 18 ]   [ Rating: 0 ]
Joined: 2010-01-24
100 posts

http://www.devshed.com/c/a/PHP/Paginating-Database-Records-with-the-Code-Igniter-PHP-Framework/

this is the link to the source code where i got the code for my pagination..

 Signature 

-the Beginner-

 
Posted: 28 January 2010 12:59 AM   [ # 19 ]   [ Rating: 0 ]
Avatar
Joined: 2009-12-16
338 posts

i don’t know what’s happening in your pagination..i’ll try to read your link of where you got your code for that..

 Signature 

“Anything executable is testable”- debug

 
Posted: 28 January 2010 02:04 AM   [ # 20 ]   [ Rating: 0 ]
Joined: 2010-01-24
100 posts

ok..i will wait.. grin
thnx a lot..

 Signature 

-the Beginner-

 
Posted: 28 January 2010 02:22 AM   [ # 21 ]   [ Rating: 0 ]
Joined: 2010-01-24
100 posts
http://localhost/helpdesk2/index.php/paging/display/&per_page=5 

this is my uri..
looks like something wrong hm??

 Signature 

-the Beginner-

 
Posted: 28 January 2010 02:31 AM   [ # 22 ]   [ Rating: 0 ]
Avatar
Joined: 2009-12-16
338 posts
husni - 28 January 2010 07:22 AM
http://localhost/helpdesk2/index.php/paging/display/&per_page=5 

this is my uri..
looks like something wrong hm??

like what’s wrong with your uri???

 Signature 

“Anything executable is testable”- debug

 
Posted: 28 January 2010 02:34 AM   [ # 23 ]   [ Rating: 0 ]
Joined: 2010-01-24
100 posts

the ‘&’ sign after the ‘/’??
huhu..
i don’t know what is th eproblem..so i just guess..

 Signature 

-the Beginner-

 
Posted: 28 January 2010 02:39 AM   [ # 24 ]   [ Rating: 0 ]
Avatar
Joined: 2009-12-16
338 posts

your uri should be look like this:

http://localhost/helpdesk2/index.php/paging/display/5 

not this:

http://localhost/helpdesk2/index.php/paging/display/&per_page=5 

can you post your updated controller??

 Signature 

“Anything executable is testable”- debug

 
Posted: 28 January 2010 02:45 AM   [ # 25 ]   [ Rating: 0 ]
Joined: 2010-01-24
100 posts
maria clara - 28 January 2010 07:39 AM

your uri should be look like this:

http://localhost/helpdesk2/index.php/paging/display/5 

not this:

http://localhost/helpdesk2/index.php/paging/display/&per_page=5 

can you post your updated controller??

that’s why i said something wrong with my uri..
this is my controller..

<?php
class Paging extends Controller{

    
function Paging(){

        
// load controller parent
    
        
parent::Controller();
    
        
// load 'Users' model
    
        
$this->load->model('Helpdesk_model');

    
}

    
function display($row=0){

        
// load pagination library
        
        
$this->load->library('pagination');
        
        
// set pagination parameters
        
        
$config['base_url']='http://localhost/helpdesk2/index.php/paging/display/';
        
        
$config['total_rows']=$this->Helpdesk_model->getNumReport();
        
        
$config['per_page']='5';
        
//$config['uri_segment'] = '3';
        
        
$this->pagination->initialize($config);
        
        
// to multiply your offset by your $config[‘per_page’]
        //That should get rid of the mysql error if no page is specified too
        
if (isset($page) && is_numeric($page)) 
            
{
                  $offset 
$page;  //Because if the page is 1 then the offset should be 0
            
}
            
else
            
{
              $offset 
0;
            

            
        $data[
'query'$this->Helpdesk_model->getAllReport(5,$offset);
        
        
// store data for being displayed on view file
        
        
$data['reports']=$this->Helpdesk_model->getReport($row);
        
        
$data['title']='Displaying Report data';
        
        
$data['header']='Report List';
        
        
$data['links']=$this->pagination->create_links();
        
        
// load 'testview' view
        
        
$this->load->view('report_view',$data);

    
}

}

?> 
 Signature 

-the Beginner-

 
Posted: 28 January 2010 02:53 AM   [ # 26 ]   [ Rating: 0 ]
Avatar
Joined: 2009-12-16
338 posts

can you try this:

....

 
$this->load->model('Helpdesk_model');

 
$data['query'$this->Helpdesk_model->getNumReport($config['per_page'],$this->uri->segment(3)); 

..... 

or

....

 
$this->load->model('Helpdesk_model');

 
$data['query'$this->Helpdesk_model->getAllReport($config['per_page'],$this->uri->segment(3)); 

..... 
 Signature 

“Anything executable is testable”- debug

 
Posted: 28 January 2010 03:08 AM   [ # 27 ]   [ Rating: 0 ]
Joined: 2010-01-24
100 posts
maria clara - 28 January 2010 07:53 AM

can you try this:

....

 
$this->load->model('Helpdesk_model');

 
$data['query'$this->Helpdesk_model->getNumReport($config['per_page'],$this->uri->segment(3)); 

..... 

or

....

 
$this->load->model('Helpdesk_model');

 
$data['query'$this->Helpdesk_model->getAllReport($config['per_page'],$this->uri->segment(3)); 

..... 

where should i put the given code?

got this error

A Database Error Occurred

Error Number: 1064

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘&per_page=5, 5’ at line 1

SELECT * FROM tblreport ORDER BY report_id ASC LIMIT &per_page=5, 5

this one also when i put the code after

$this->load->model(‘Helpdesk_model’);

A PHP Error was encountered

Severity: Notice

Message: Undefined variable: config

Filename: controllers/paging.php

Line Number: 14

 Signature 

-the Beginner-

 
Posted: 28 January 2010 03:16 AM   [ # 28 ]   [ Rating: 0 ]
Avatar
Joined: 2009-12-16
338 posts

or so, try to put this line
$this->load->model(‘Helpdesk_model’);
$data[‘query’] = $this->Helpdesk_model->getNumReport($config[‘per_page’],$this->uri->segment(3));
inside your function display($row==0)

or if it still don’t work just take out this:

$data['query'$this->Helpdesk_model->getNumReport($config['per_page'],$this->uri->segment(3)); 
 Signature 

“Anything executable is testable”- debug

 
Posted: 28 January 2010 03:23 AM   [ # 29 ]   [ Rating: 0 ]
Joined: 2010-01-24
100 posts
maria clara - 28 January 2010 08:16 AM

or so, try to put this line
$this->load->model(‘Helpdesk_model’);
$data[‘query’] = $this->Helpdesk_model->getNumReport($config[‘per_page’],$this->uri->segment(3));
inside your function display($row==0)

or if it still don’t work just take out this:

$data['query'$this->Helpdesk_model->getNumReport($config['per_page'],$this->uri->segment(3)); 

my uri still the same..
i wonder why my uri can be like that?
do you have any idea?

 Signature 

-the Beginner-

 
Posted: 28 January 2010 03:27 AM   [ # 30 ]   [ Rating: 0 ]
Joined: 2010-01-24
100 posts

http://localhost/helpdesk2/index.php/paging/display/5

when i put this uri manually..it display the other 5 set of data..
and when i click number 2, the uri will be change to the

http://localhost/helpdesk2/index.php/paging/display/&per_page=5

configuration maybe??

 Signature 

-the Beginner-

 
2 of 3
2