Warum bekomme ich alle Daten auf derselben Seite?Codeigniter Bootstrap Paginierung (Seite zeigt alle Daten in derselben Tabelle an)
Die Funktion funktioniert, da sie die Seite (1,2,3) als Anzahl der Daten in der Datenbanktabelle anzeigt. Aber zeigt die Daten alle auf einer Seite an.
Controller Seite meiner Anwendung ruft er die Bootstrap-Paginierung
public function reportTransaction(){
//pagination settings followed from that tutorial
//base url defined application
$config['base_url'] = site_url('inventory/reportTransaction');
//code that gets rows from the transaction model
$config['total_rows'] = $this->transactionLog->countAll();
//defined per page as 5
$config['per_page'] = 5;
$config["uri_segment"] = 3;
$choice = $config["total_rows"]/$config["per_page"];
$config["num_links"] = ceil($choice);
//echo $config["num_links"];
//config for bootstrap pagination class integration
$config['full_tag_open'] = '<ul class="pagination">';
$config['full_tag_close'] = '</ul>';
$config['first_link'] = false;
$config['last_link'] = false;
$config['first_tag_open'] = '<li>';
$config['first_tag_close'] = '</li>';
$config['prev_link'] = '«';
$config['prev_tag_open'] = '<li class="prev">';
$config['prev_tag_close'] = '</li>';
$config['next_link'] = '»';
$config['next_tag_open'] = '<li>';
$config['next_tag_close'] = '</li>';
$config['last_tag_open'] = '<li>';
$config['last_tag_close'] = '</li>';
$config['cur_tag_open'] = '<li class="active"><a href="#">';
$config['cur_tag_close'] = '</a></li>';
$config['num_tag_open'] = '<li>';
$config['num_tag_close'] = '</li>';
$this->pagination->initialize($config);
$data['page'] = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
//call the model function to get the transaction data
$data['posts'] = $this->transactionLog->get_report();
$data['pagination'] = $this->pagination->create_links();
//print_r($data['posts']);
//load the department_view
$this->load->view('admin/reportTransaction', $data);
$this->header();
$this->footer();
}
Modell, das in der Steuerung genannt
function get_report($limit = null)
{
if ($limit != null) {
$this->db->limit($limit['limit'], $limit['offset']);
}
$q = $this->db->query("SELECT `transaction`.`transaction_id`, ABS(`cost`) as cst,`transaction`.`date_posted`, ABS(`unit`) as unt, `detail`.`name` as sam, `product`.`productName` as pam, `transaction`.`type` FROM `transaction` INNER JOIN `detail` ON `detail`.`type`=`transaction`.`type` INNER JOIN `product` ON `product`.`product_id`=`transaction`.`product_id`");
// $q = $this->db->get($this->table);
if ($q->num_rows() > 0) {
foreach ($q->result() as $row)
{
$data[] = $row;
}
}
return $data;
}
function countAll()
{
return $this->db->count_all($this->table);
}
VIEW Seite der Anwendung, die die Daten aus dem Controller zeigt !! Dies ist die Tabelle, die die Daten in der gleichen Seite zeigt
<table class="table tablesorter table-bordered table-hover table-striped sortable">
<thead>
<tr>
<th>S/B Name</th>
<th>Product Name</th>
<th>Unit</th>
<th>Date Posted</th>
</tr>
</thead>
<tbody>
<?php $i=1; foreach($posts as $post): ?>
<tr <?=($i % 2 == 0) ? 'class="even"' : '' ?>>
<td><?=$post->sam?></td>
<td><?=$post->pam?></td>
<td><?=$post->unt?></td>
<td><?=$post->date_posted?></td>
</tr>
<?php $i++; endforeach; ?>
</tbody>
</table>
<div class="row">
<div class="col-md-12 text-center">
<p><?php echo $pagination; ?></p>
</div>
</div>
</div>
Problem, das in dem System kam Alle Daten in derselben Seite angezeigt werden Paginierung Seitenzahl steigt nach Daten, sondern in derselben Tabelle angezeigten Daten
zeigen Sie Ihre 'get_report()' Methode von 'transactionLog' Modell. Vielleicht Limit Problem dort –
Rejoanul Ich habe die get_report aus transactionLog code .. –
Sie können nicht paginiert Ergebnisse erhalten, es sei denn, Sie überschreiten ein "Limit" und "Offset" in Ihr Modell. – Sparky