-1

I have created a page using following link 1 in codeigniter.I have displayed the abstract in one line and author in second line using echo get_abstract($row->id=1).For second record i have to change id=2 and so on. Is there any way to create next and previous button in view so that when i click on next id would automatically get incremented and display record. Similarly for previous also.Right now I am using following view.php

<?php 
if($fetch_data->num_rows() > 0)  
{  
    $row = $fetch_data->row(); 
    echo get_Author($row->DocumentID=1);
}?>

<?php 
if($fetch_data->num_rows() > 0)  
{  
    $row = $fetch_data->row(); 
    echo get_Abstract($row->DocumentID=1);
}?> 

You can see that i am using fixed id (DocumentID) to display records of 1st row of mysql.I want to change it dynamically by clicking next, previous in view rather than manually assigning.

The model and controller are defined in above link.I will be grateful to you for your help.

Kumar Ajeet
  • 72
  • 12
  • check the `pagination class` library of CI. – ilias-sp Jun 28 '18 at 23:45
  • show ur view for next and previous buttons also – Pradeep Jun 29 '18 at 01:18
  • i have tried pagination.In all examples, we can display tables and can control number of row using $data['table'] = $this->Sample_model->get_limited_data(1, $this->uri->segment(3));. But my idea is different.I already created view page by separatly displaying individual filed of table by assigning iD.is it possible to change it by clicking some button next? – Kumar Ajeet Jun 29 '18 at 02:29
  • Still creating next and previous buttion.Is there any way to increment output ID.If we assign initial id as 1 then we can click next to get next id and data??? – Kumar Ajeet Jun 29 '18 at 02:31

1 Answers1

0

I have solved this problem by adding following model class and adding pagination in controller.

function fetch_data($limit, $offset=0)  
        {  
        $this->db->limit($limit,$offset);

        $query = $this->db->get('prlaps');
        return $query; 
Kumar Ajeet
  • 72
  • 12