At first connect the database in your project file and connect the model page in your view page and try this code.
View Page:
<?php $get_data=$this->MyModel->get_table_data(); ?> <table class="table table-bordered"> <thead> <tr> <th> Name </th> <th> Email </th> <th> Phone No </th> </tr> </thead> <tbody> <?php foreach($get_data as $val){ ?> <tr> <td><?php echo $val->name; ?></td> <td><?php echo $val->email; ?></td> <td><?php echo $val->phone; ?></td> </tr> <?php } ?> </tbody> </table>
Model Page:
public function get_table_data(){ $qry=$this->db->select('*')->from('Table Name')->get()->result(); return $qry; }
Question and answer is powered by AnsPress.io