du måste göra en kontroll innan du börjar iterera för data, som:modellkod:
public function getAll() {
$results = array();
$this->db->select('bcode, bname, btel, badd');
$this->db->from('branches');
$query = $this->db->get();
if($query->num_rows() > 0) {
$results = $query->result();
}
return $results;
}
visa kod:
if( !empty($results) ) {
foreach($results as $row) {
echo '<tr>';
echo '<td>'.$row->bcode.'</td>';
echo '<td>'.$row->bname.'</td>';
echo '<td>'.$row->btel.'</td>';
echo '<td>'.$row->badd.'</td>';
echo '</tr>';
}
}