Welcome Guest, Not a member yet? Register   Sign In
using pagination with SQL server 2008 database
#1

hello, coder.
now i am making a website application using codeigniter 3 with SQL server 2008 database.
I want to use the pagination feature to display all records with 10 records per page.
I've created the MVC file and the record and pagination buttons have been displayed.
but when I will press the next button in the pagination button to display the next record, nothing happens. in other words still remain on the first page with the first record shown (10 records shown).
here is my MVC
controller:
PHP Code:
<?php
defined
('BASEPATH') OR exit('No direct script access allowed');

class 
Menu extends CI_Controller
{
    
    public function 
server1()
    {
        
$this->load->view('server/db1');
    }
    
        public function 
iat_dev()
        {
            
$this->load->view('server/db1/iat_dev');
        }
        
        public function 
iat_live()
        {
            
$this->load->view('server/db1/iat_live');
        }
        
        public function 
iat_test()
        {
            
$this->load->view('server/db1/iat_test');
        }
        
        public function 
iatm()
        {
            
$this->load->view('server/db1/iatm');
        }
        
        public function 
imp_sys()
        {
            
$this->load->view('server/db1/imp_sys');
        }
        
        public function 
import_statistic()
        {
            
$this->load->view('server/db1/import_statistic');
        }
        
            public function 
galic()
            {
                
$this->load->helper(array('url'));
                
$this->load->model('server/db1/import_statistic/model_galic');
                
$this->load->library('kode_negara'); //library buatan sendiri
                
$this->kode_negara->list_negara();
                
$this->load->library('pagination');
                
                
//$kueri = $this->model_galic->tampil_data(); //$this->[class model]->[function model]();
                //$data = array('hasil' => $kueri); //array('[variabel yg ditampilkan di view]'
                
                
$config['base_url'] = base_url().'menu/galic';
                
$config['total_rows'] = $this->db->get('galic')->num_rows();
                
$config['per_page'] = 10;
                
                
$config['first_link'      'Pertama';
                
$config['last_link'       'Terakhir';
                
$config['next_link'       'Berikut';
                
$config['prev_link'       'Sebelum';
                
$config['full_tag_open'   '<div class="text-center"><nav><ul class="pagination justify-content-center">';
                
$config['full_tag_close'  '</ul></nav></div>';
                
$config['num_tag_open'    '<li class="page-item"><span class="page-link">';
                
$config['num_tag_close'   '</span></li>';
                
$config['cur_tag_open'    '<li class="page-item active"><span class="page-link">';
                
$config['cur_tag_close'   '<span class="sr-only">(current)</span></span></li>';
                
$config['next_tag_open'   '<li class="page-item"><span class="page-link">';
                
$config['next_tagl_close' '<span aria-hidden="true">&raquo;</span></span></li>';
                
$config['prev_tag_open'   '<li class="page-item"><span class="page-link">';
                
$config['prev_tagl_close' '</span></li>';
                
$config['first_tag_open'  '<li class="page-item"><span class="page-link">';
                
$config['first_tagl_close'] = '</span></li>';
                
$config['last_tag_open'   '<li class="page-item"><span class="page-link">';
                
$config['last_tagl_close' '</span></li>';
                
//class disabled untuk menonaktifkan 
                
                
$from $this->uri->segment(3);
                
$this->pagination->initialize($config);
                
$data['hasil'] = $this->model_galic->tampil_data($config['per_page'],$from);
                
$this->load->view('server/db1/import_statistic/galic'$data);
            }
            
            public function 
ikpp()
            {
                
$this->load->view('server/db1/import_statistic/ikpp');
            }
            
            public function 
master_imp()
            {
                
$this->load->view('server/db1/import_statistic/master_imp');
            }
            
            public function 
tblrpths()
            {
                
$this->load->view('server/db1/import_statistic/tblrpths');
            }
            
            public function 
tk()
            {
                
$this->load->view('server/db1/import_statistic/tk');
            }
            
        public function 
reportserver()
        {
            
$this->load->view('server/db1/reportserver');
        }
        
        public function 
reportservertempdb()
        {
            
$this->load->view('server/db1/reportservertempdb');
        }
        
    public function 
server2()
    {
        
$this->load->view('server/db2');
    }
    
    public function 
database()
    {
        
$this->load->view('info/db');
    }
    
    public function 
versiphp()
    {
        
$this->load->view('info/php');
    }
    

model:
PHP Code:
<?php
defined
('BASEPATH') OR exit('No direct script access allowed');

class 
Model_galic extends CI_Model
{
    function 
tampil_data(){
        
$this->load->database('sqlsrv_import_statistic'TRUE);
        
$limit '1';
        
$offset '10';
        
$sql "DECLARE
                @LIMIT AS INT = 
$limit,
                @OFFSET AS INT = 
$offset
                SELECT  *
                FROM    ( SELECT    ROW_NUMBER() OVER ( ORDER BY convert(datetime,tanggalPIB,103) ) AS NoBaris, *
                          FROM      GALIC
                        ) AS RowConstrainedResult
                WHERE   NoBaris >= 
$limit
                AND     NoBaris <= 
$offset
                ORDER BY NoBaris"
;
        
$query $this->db->query($sql);
        return 
$query;
    }

view:
PHP Code:
<?php
defined
('BASEPATH') OR exit('No direct script access allowed');
?>
<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Indo Asia | Tabel GALIC</title>
            <?php include 'application/views/komponen/header.php'//meta, css, js ?>
    </head>
<body>
    <?php include 'application/views/komponen/navbar.php'//navbar ?>

<div class="container text-center">    
    <div class="row content">
        <div class="col-sm-12 text-left"> 
            <h2>Tabel GALIC</h2>
            <hr>
            <form class="form" action="<?php echo base_url() ?>menu/cari_galic" method="POST">
                <div class="form-row">
                    <div class="form-group col-md-2">
                        <label for="label_hs">HS:</label>
                        <input type="text" class="form-control form-control" name="hs" placeholder="Kode HS" />
                    </div>                
                    <div class="form-group col-md-4">
                        <label for="label_importir">Importir:</label>
                        <input type="text" class="form-control form-control" name="importir" placeholder="Nama Importir" />
                    </div>
                    <!--datepicker awal-->
                    <div class="form-group col-md-2">
                    <label for="label_tglawal">Tanggal Awal:</label>
                        <div class="input-daterange" id="datepicker">
                            <input type="text" class="form-control form-control" name="tglawal" placeholder="MM/DD/YYYY" />
                        </div>
                    </div>    
                    <div class="form-group col-md-2">
                    <label for="label_tglakhir">Tanggal Akhir:</label>                    
                        <div class="input-daterange" id="datepicker">
                            <input type="text" class="form-control form-control" name="tglakhir" placeholder="MM/DD/YYYY" />
                        </div>
                    </div>
                    <!--datepicker akhir-->
                </div>
                <button type="submit" class="btn btn-primary" id="tabel" value="cari">Cari</button>
            </form>
            <br />
            <div class="table-responsive">
                <table class="table table-hover table-bordered">
                    <thead class="thead-dark">
                        <tr>
                            <th>No</th>
                            <th>NoPengajuan</th>
                            <th>TanggalPIB</th>
                            <th>TanggalBLAWB</th>
                            <th>PelabuhanAsal</th>
                            <th>PelabuhanTujuan</th>
                            <th>NPWP</th>
                            <th>Importir</th>
                            <th>AlamatImportir</th>
                            <th>PPJK</th>
                            <th>AlamatPPJK</th>
                            <th>Pemasok</th>
                            <th>AlamatPemasok</th>
                            <th>NegaraPemasok</th>
                            <th>HS</th>
                            <th>UraianBarang</th>
                            <th>Quantity</th>
                            <th>KodeSatuan</th>
                            <th>Berat</th>
                            <th>HargaCIF</th>
                            <th>MataUang</th>
                        </tr>
                    </thead>
                    <?php
                        $no
=1;
                        foreach(
$hasil->result() as $baris)
                        {
                    
?>
                    <tbody>
                        <tr>
                            <td align="right"><?php echo number_format($no++,0,",",".")?></td>
                            <td><?php echo $baris->NoPengajuan?></td>
                            <td><?php echo $baris->TanggalPIB?></td>
                            <td><?php echo $baris->TanggalBLAWB?></td>
                            <td><?php echo $baris->PelabuhanAsal?></td>
                            <td><?php echo $baris->PelabuhanTujuan?></td>
                            <td><?php echo $baris->NPWP?></td>                        
                            <td><?php echo $baris->Importir?></td>
                            <td><?php echo $baris->AlamatImportir?></td>
                            <td><?php echo $baris->PPJK?></td>
                            <td><?php echo $baris->AlamatPPJK?></td>
                            <td><?php echo $baris->Pemasok?></td>
                            <td><?php echo $baris->AlamatPemasok?></td>
                            <td><?php echo strtoupper($this->kode_negara->list_negara($baris->NegaraPemasok)); ?></td>
                            <td><?php echo $baris->HS?></td>
                            <td><?php echo $baris->UraianBarang?></td>
                            <td align="right"><?php echo number_format($baris->Quantity,0,",","."); ?></td>
                            <td><?php echo $baris->KodeSatuan?></td>
                            <td align="right"><?php echo number_format($baris->Berat,0,",","."); ?></td>
                            <td align="right"><?php echo number_format($baris->HargaCIF,2,",","."); ?></td>
                            <td><?php echo $baris->MataUang?></td>
                        </tr>
                    </tbody>
                    <?php
                        
}
                    
?>
                </table>
            </div>
            <?php
                
echo '<p>'.$this->db->count_all_results('galic'/*nama tabel*/).' record(s) ditampilkan</p>';
                echo 
$this->pagination->create_links();
            
?>
        </div>
    </div>
</div>

    <?php include 'application/views/komponen/footer.php'//footer ?>
</body>
</html> 
where is my syntax writing error?
I am very happy if you help me.
thank you Smile

Thanks

CodeIgniter-Indonesia
Reply




Theme © iAndrew 2016 - Forum software by © MyBB