All you need to do is copy the following code to your view file and call the view from controller and pass the table data as todos. i.e. $data['todos']=$query->result. $this->load->view('view',$data).
<?php
echo "<table>";
//print table headers
if($todos){
echo "<thead>";
foreach($todos[0] as $key=>$val){
echo "<td> $key </td>";
}
echo "</thead>";
//print data
foreach($todos as $todo){
echo "<tr>";
foreach($todo as $key => $val){
echo "<td> $val </td>";
}
echo "<tr>";
}
}else{
echo "<h1>Sorry, No Todo is available</h1>";
}
?>
</table>
No comments:
Post a Comment