du skal foretage et tjek, før du begynder at iterere dataene, f.eks.:modelkode:
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;
}
se kode:
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>';
}
}