I want to display my database record in a table, but I don't get it. I don't know whats wrong in my code but it displays empty result. I have attached my model and view. I am using codeigniter framework. Any help would be much appreciated..
Here is my model:
public function display_data(){
$query = $this->db->query("SELECT * FROM sales_rep_tbl;");
if($query->num_rows > 0){
$this->table->set_heading(
"SR_Code",
"SR_Fname"
);
foreach($query->result() as $r){
$bg = "black";
$this->table->add_row(
"<div class = '".$bg."'>".$r->SR_Code."</div>",
"<div class = '".$bg."'>".$r->SR_Lname."</div>",
"<div class = '".$bg."'>".$r->SR_Fname."</div>"
);
$data.= $this->table->generate().br();
}
return $data;
}
}
And my view:
<div class = "container" >
<div class = "row" style = " height:400px; width:auto; margintop:20px;" >
<div class = "col-xs-12">
<?php echo $this->Main_Page_Model->display_data();?>
</div>
</div>
</div>