Welcome Guest, Not a member yet? Register   Sign In
please help - codeigniter search and pagination
#1

[eluser]Unknown[/eluser]
hi,
please help me with this problem
i have one one table connected with database,

i want to add feature pagination and select in that database but already try and error

my code is like this :

app/ VIEWS
Code:
<div id="data">  
    <div id="loading" ></div>    
                <table border="0" width="100%" cellspacing="0" class="table table-bordered">
                <tr>
     <th><center>No</center></th>
                    <th><center>PO_NO</center></th>
                    <th><center>Start_Date</center></th>
                    <th><center>New_Project_ID</center></th>
                    <th><center>Activity_ID</center></th>                    
                    <th colspan="2"><center>Aksi</center></th>
                </tr>
                &lt;?php
    $i=1;
    foreach($data as $baris){?&gt;
                <tr>
                    <td>&lt;?php echo $i ?&gt;</td>
                    <td>&lt;?php echo $baris->PO_NO ?&gt;</td>
                    <td>&lt;?php echo $baris->Start_Date ?&gt;</td>
                    <td>&lt;?php echo $baris->New_Project_ID ?&gt;</td>
                    <td><center>&lt;?php echo $baris->Activity_ID ?&gt;<center></td>                  
                    <td width="80"><center><a class="btn btn-small" href="#"><i class="icon-pencil"></i> EDIT</a></center></td>
                    <td width="80"><center><a class="btn btn-small" href="#"><i class="icon-trash"></i> HAPUS</a></center></td>
                </tr>
                &lt;?php
    $i++;
    }?&gt;
                </table>
    &lt;?php echo $this->pagination->create_links(); ?&gt;
            </div>

app/controllers

Code:
function __construct(){
        parent::__construct();
    //    $this->load->model('modeldata');
    }
    
    function index(){
        $data['judul'] = 'Data PO';
       //  $data['data'] = $this->modeldata->getDatadata();
    
  
  //add
  
  $this->load->library('pagination');
  $this->load->library('table');
  
  $config['base_url'] = 'http://localhost/cig/index.php/site/index';
  $config['total_rows'] = $this->db->get('po_data')->num_rows();
  $config['per_page'] = 10;
  $config['num_links'] = 20;
  $config['full_tag_open'] = '<div id="pagination">';
  $config['full_tag_close'] = '</div>';
  
  $this->pagination->initialize($config);
  
  $data['data'] = $this->db->get('po_data', $config['per_page'], $this->uri->segment(3));
  //add
   $this->load->view('v_data',$data);

and got error like this

[Image: 2r78pdz.png]

before i try to add pagination and search the page like this
[Image: i5n8n7.png]

can someone help me with this
#2

[eluser]boony[/eluser]
Hi,

Having a look at the error in the first link it looks like you are not getting anything from the database. Check the $data array to make sure you are getting the correct data. Do a var_dump($data) just above the foreach loop to check.

Of course there may be something else going on but this would be my first check.

Boony
#3

[eluser]Pert[/eluser]
Change foreach($data as $baris) to foreach($data<b>['data']</b> as $baris)




Theme © iAndrew 2016 - Forum software by © MyBB