Welcome Guest, Not a member yet? Register   Sign In
how to display database in a table (like a datagrid view with edit/delete functions)
#1

[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>";
?&gt;


&lt;?php else : ?&gt;
<h2>No records were returned.</h2>
&lt;?php endif; ?&gt;

thank you




Theme © iAndrew 2016 - Forum software by © MyBB