I want to display all records from database to my view page. Having a table customers
, how can I display all records of this table?
Here is my customer_model.php file..
function all_customss()
{
$query=$this->db->query("select * from customers");
return $query->result();
}
Here are my controller.php file...
function viewpage()
{
$result['data'] = $this->customer_model->all_customss();
$this->load->view('models_view', $result);
}
And here is the link which will display all records after click...
<div class="col-md-12 col-sm-12 text-center"><a class="btn btn-default hvr-bounce-to-right" href="<?php echo site_url('/viewpage/');?>" role="button"><?php echo $this->lang->line('see_more'); ?></a>
and here is my view file...page_view.php
tr><td><?php
$i=1;
foreach($data as $row)
{
echo "<tr>";
echo "<td>".$i."</td>";
echo "<td>".$row->firstname."</td>";
echo "<td>".$row->lastname."</td>";
echo "<td>".$row->email."</td>";
echo "</tr>";
$i++;
}
?></td></tr>