Welcome Guest, Not a member yet? Register   Sign In
Pagination not working
#1

[eluser]bhakti.thakkar[/eluser]
i have a page in which i display all the projects of a particular client. e.g. there are 24 records for a particular client. but i get all the 24 records at a stretch in my view. i have specified 5 records per page but it doesnt work. there are proper ‹ First < 1 2 3 4 5 > on my view page but all 24 records are shown on all the links. what is wrong ? please help me

Controller : projects.php:

Code:
function index()
    {
        $start = (int) $this->uri->segment(3);
        ($start) ? $lower = $start : $lower = 0;

        $this->load->library('pagination');
        $config['base_url'] = base_url().'index.php/projects/index/';
         $config['uri_segment'] = 3;
        $config['total_rows'] = $this->projects_model->ProjectCount(); // returns 24 rows
        $offset = (int) $this->uri->segment(3, 0);
        $config['per_page'] = '5';

//        $config['num_links'] = 5;
        $config['full_tag_open'] = '<p class="pagination">';
        $config['full_tag_close'] = '</p>';
        $this->pagination->initialize($config);  
        $data['pagination'] = $this->pagination->create_links();

        $data['query'] = $this->projects_model->getProjects($lower, $config['per_page']);
        $data['total_rows'] = ($data['query']) ? $data['query']->num_rows() : 0;

    
        $data['message'] = ($this->session->flashdata('message') != '') ? '<p class="error">'.$this->session->flashdata('message').'</p>' : '';
        $data['page_title'] = 'Projects';
        $this->load->view('projects/index', $data);
    }

my view :

Code:
&lt;?php
if (isset($pagination)) {
    echo $pagination;
}
?&gt;
<table class="stripe" id="invoiceListings">
  <tbody id="invoiceRows">
    <tr>
      <th class="invNum" width="8%">Sr. no.</th>
      <th class="invNum">Project ref.</th>
      <th class="dateIssued">Name</th>
    </tr>
&lt;?php
if (isset($total_rows) && $total_rows == 0):
?&gt;
    <tr>
      <td colspan="5">No records found
      </td>
    </tr>
&lt;?php
else:

    $i=0;
    foreach($query->result() as $row):
    $i++;
?&gt;

    <tr>
      <td>&lt;?=$i?&gt;</td>
      <td>&lt;?php echo anchor('invoices/view/'.$row->Project_ID,$row->Project_ID);?&gt;</td>
     <td>&lt;?php echo anchor('invoices/view/'.$row->Project_VC, htmlentities($row->Project_VC));?&gt;</td>

    </tr>
    &lt;?php
    endforeach;
    endif;
    ?&gt;
  </tbody>
</table>


Model :
[code]
    function getProjects()
    {
        return $this->_getProjects();
    }

    // --------------------------------------------------------------------


    function _getProjects($offset=0, $limit=100)
    {
        $relation_id = $this->session->userdata('srelation_id');
        // check for any invoices first
        if ($this->db->count_all_results('Project_T') < 1)
        {
            return FALSE;
        }


        $this->db->select(' * ');
        $this->db->where(" Relation_ID = '$relation_id' and Deleted_DT is null");
        
        $this->db->offset($offset);
        $this->db->limit($limit);
        return $this->db->get('Project_T');
    }
Thanks in anticipation


[/code]


Messages In This Thread
Pagination not working - by El Forum - 11-14-2008, 12:33 AM
Pagination not working - by El Forum - 11-14-2008, 01:24 AM
Pagination not working - by El Forum - 11-14-2008, 01:53 AM
Pagination not working - by El Forum - 11-14-2008, 04:11 AM
Pagination not working - by El Forum - 11-14-2008, 05:41 AM
Pagination not working - by El Forum - 11-15-2008, 05:01 AM
Pagination not working - by El Forum - 11-16-2008, 10:41 PM
Pagination not working - by El Forum - 11-16-2008, 11:23 PM
Pagination not working - by El Forum - 12-02-2008, 01:51 PM
Pagination not working - by El Forum - 12-03-2008, 03:17 AM



Theme © iAndrew 2016 - Forum software by © MyBB