我正在使用codeigniter的網站上工作,並且我有這張表格將充滿來自數據庫的信息。 當我填充我的表格時,需要相當長的一段時間,因爲我的數據庫中有15000行,並且瀏覽器在加載一兩分鐘後卡住了。使用許多元素填充表格
這裏是我的代碼部分
查看:
<div class="portlet-body">
<table class="table table-striped table-bordered table-hover table-full-width" id="sample_1">
<thead>
<tr>
<th>ID</th>
<th class="hidden-xs">Serial Number</th>
<th class="hidden-xs">Codigo</th>
<th class="hidden-xs">Estado</th>
<th class="hidden-xs">Data de inserção</th>
<th class="hidden-xs">Provider</th>
</tr>
</thead>
<tbody>
<?php foreach ($query->result_array() as $row): {
?>
<tr>
<td><?php echo $row['product_id'] ?></td>
<td><?php echo $row['serial_number'] ?></td>
<td class="hidden-xs"><?php echo $row['product_code'] ?></td>
<td class="hidden-xs"><?php echo $row['product_status'] ?></td>
<td class="hidden-xs"><?php echo $row['product_insertion_date'] ?></td>
<td class="hidden-xs"><?php echo $row['product_provider'] ?></td>
</tr>
<?php } endforeach; ?>
</tbody>
</table>
</div>
控制器:
public function loadProdutos(){
$this->load->model('produtos_model');
$tmp = $this->produtos_model->getProdutos();
$data['query'] = $tmp;
$this->load->view('produtos',$data);
}
型號:
function getProdutos() {
$query = $this->db->get('products');
return $query;
}
我的問題是,如果有一個最佳實踐在這種類型中情況,還是其他方式做到這一點?