[eluser]Unknown[/eluser]
hi! I've researched this on the internet and I was able to come up with this code, but it does not seem to work well... It keeps displaying that there is no record even though there actually are records in the table
This is my controller
Code:
public function tblLoad(){
$data = array();
if($query = $this->crudModel->rec_getall())
{
$data['members'] = $query;
}
$this->load->view('LandingPage', $data);
}
this is my model
Code:
function rec_getall()
{
$this->load->database();
//$query = $this->db->query('SELECT name,department,local FROM employee WHERE is_del=0 ');
$query = $this->db->get('employee');
return $query->result();
}
view
Code:
<?php
echo "<table border=1>";
echo "<tr>";
echo "<td>username</td>";
echo "<td>password</td>";
echo "<td>level</td>";
echo "<td> </td>";
echo "</tr>";
if(isset($records)) : foreach($records as $row){
echo "<tr>";
echo "<td>".$row->username."</td>";
echo "<td>".$row->password."</td>";
echo "<td>".$row->level."</td>";
echo "<td>". anchor('login/AddEmp', 'Add Employee') | anchor('login/AddEmp', 'Add Employee') ."</td>";
//fix this
echo "</tr>";
}
echo "</table>";
?>
<?php else : ?>
<h2>No records were returned.</h2>
<?php endif; ?>
thank you