CodeIgniter Forums
Pagination Problem Help me ... - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: Pagination Problem Help me ... (/thread-25751.html)

Pages: 1 2


Pagination Problem Help me ... - El Forum - 12-23-2009

[eluser]Sathishkumar[/eluser]
Hi,
Iam newbie in CI. Pagination problem to my site ... its my code


Controller :

Code:
$this->load->model('excute');        
$this->load->database();
$this->load->helper(array('url','form'));
$this->load->library('session');
$this->load->library('pagination');
$config['base_url'] = base_url().'index.php/student_submit/index';
$config['total_rows'] = count($this->excute->get_course2());
$config['per_page'] = 5;
$config['full_tag_open'] = '<p>';
$config['full_tag_close'] = '</p>';
$this->pagination->initialize($config);

$ddata['course'] = $this->excute->get_course2($config['per_page'],$this->uri->segment(3));
$this->load->view('student_submit',$ddata);

View :
Code:
&lt;?php
foreach($course as $key => $value):
?&gt;
  
&lt;input type="checkbox" name="course[]" value="&lt;?php echo $value['course_id']; ?&gt;" /&gt;
&lt;?php echo $value['course_id']; ?&gt;
&lt;?php echo $value['course_name']; ?&gt;
&lt;?php echo $value['subject_id']; ?&gt;
&lt;?php echo $value['course_no_of_seats']; ?&gt;
&lt;?php echo $value['course_enroll_no']; ?&gt;
&lt;?php endforeach;?&gt;
&lt;?php echo $this->pagination->create_links(); ?&gt;

Model
Code:
function get_course2()
  {
        $this->load->database();
        $this->load->library('pagination');
        $query = $this->db->query("SELECT * FROM course WHERE no_of_seats > enroll_no");
        $total_rows=$query->num_rows();
        if($total_rows>0)  
        {
            foreach($query->result_array() as $row)
            {
                 $result[] = $row;            
            }
            return $result;
        }        
        else
           return 'null';      
  }

Please anybody Help Me....


Pagination Problem Help me ... - El Forum - 12-23-2009

[eluser]flaky[/eluser]
what is exactly the problem?


Pagination Problem Help me ... - El Forum - 12-23-2009

[eluser]SpooF[/eluser]
I'm going to take a guess at this and say that the links aren't working. The reason most likely being is that your not setting a uri_segment.

It seems this is the number one cause of problems with the pagination class.


Pagination Problem Help me ... - El Forum - 12-23-2009

[eluser]Sathishkumar[/eluser]
Pagination links created but shows all rows ...

http://i46.tinypic.com/s33ibl.jpg


Pagination Problem Help me ... - El Forum - 12-23-2009

[eluser]SpooF[/eluser]
This probably has something to do with your model and not the pagination class. The pagination class doesn't control how many entries to display. It simple gives you a starting point for your query.


Pagination Problem Help me ... - El Forum - 12-23-2009

[eluser]saidai jagan[/eluser]
post u r model function


Pagination Problem Help me ... - El Forum - 12-23-2009

[eluser]Sathishkumar[/eluser]
[quote author="saidai jagan" date="1261593378"]post u r model function[/quote]
model function :

Code:
function get_course2()
  {
        $this->load->database();
        $this->load->library('pagination');
        $query = $this->db->query("SELECT * FROM course WHERE no_of_seats > enroll_no");
        $total_rows=$query->num_rows();
        if($total_rows>0)  
        {
            foreach($query->result_array() as $row)
            {
                 $result[] = $row;            
            }
            return $result;
        }        
        else
           return 'null';      
  }



Pagination Problem Help me ... - El Forum - 12-23-2009

[eluser]saidai jagan[/eluser]
Code:
$ddata['course'] = $this->excute->get_course2($config['per_page'],$this->uri->segment(3));

function get_course2($per_page,$start='0')
  {
        $this->load->database();
        $this->load->library('pagination');
        $query = $this->db->query("SELECT * FROM course WHERE no_of_seats > enroll_no LIMIT ".$start.','.$per_page);
        $total_rows=$query->num_rows();
        if($total_rows>0)  
        {
            foreach($query->result_array() as $row)
            {
                 $result[] = $row;            
            }
            return $result;
        }        
        else
           return 'null';      
  }



Pagination Problem Help me ... - El Forum - 12-23-2009

[eluser]Sathishkumar[/eluser]
show's following error....

http://i49.tinypic.com/2akfyap.jpg
Code:
A PHP Error was encountered

Severity: Warning

Message: Missing argument 1 for Excute::get_course2(), called in C:\xampp\htdocs\sathishkumar2\system\application\controllers\student_submit.php on line 18 and defined

Filename: models/excute.php

Line Number: 55
Code:
A PHP Error was encountered

Severity: Notice

Message: Undefined variable: perpage

Filename: models/excute.php

Line Number: 59
Code:
A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\sathishkumar2\system\libraries\Exceptions.php:166)

Filename: codeigniter/Common.php

Line Number: 360
Code:
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 '' at line 1

SELECT * FROM course WHERE course_no_of_seats > course_enroll_no LIMIT 0 ,


55th line is :
Code:
function get_course2($perpage,$start='0')

59th line :
Code:
$query = $this->db->query("SELECT * FROM course WHERE course_no_of_seats > course_enroll_no LIMIT $start , $perpage");



Pagination Problem Help me ... - El Forum - 12-23-2009

[eluser]saidai jagan[/eluser]
will u post u r LATEST controller function and Model function ?