codeigniter - php Invalid argument supplied for foreach() -
i don't understand happen there. got problem @ line 87
$this->data['option_pengujian'][$row->id_penguji] = $row->penguji;   this code of function
public function tambah()     {         $this->data['breadcrumb']   = 'pengujian > tambah';         $this->data['main_view']    = 'view_pengujian/pengujian_form';         $this->data['form_action']  = 'pengujian/tambah';         $penguji = $this->penguji->cari_semua();         if($penguji)         {             foreach($penguji $row)             {                 $this->data['option_pengujian'][$row->id_penguji] = $row->penguji;             }         }         else         {             $this->data['option_pengujian']['00'] = '-';             $this->data['pesan'] = 'data penguji tidak tersedia. silahkan isi dahulu data penguji.';             // if submit             if($this->input->post('submit'))             {                 if($this->siswa->validasi_tambah())                 {                     if($this->siswa->tambah())                     {                         $this->session->set_flashdata('pesan', ' proses tambah data berhasil');                         redirect('pengujian');                     }                     else                     {                         $this->data['pesan'] = 'proses tambah data gagal';                         $this->load->view('template', $this->data);                     }                 }                 else                 {                     $this->load->view('template', $this->data);                 }             }             else             {                 $this->load->view('template', $this->data);             }         }     }   this cari_semua() in model
public function cari_semua()     {         return $this->db->order_by('id_penguji', 'asc')->get($this->db_tabel)->result();     }      
... foreach($penguji->row() $row){ ...   or
... foreach($penguji->result() $row){ ...   or : if want return ($penguji) array model, add (->row() or ->result()) @ end of variable you'd return.
if want easier learn, please write script neatly.
here's model
    public function cari_semua()         {             $this->db->order_by('id_penguji', 'asc');             return $this->db->get($this->db_tabel)->result();  // have made result array here.  //so, don't need use `->result` in controller.         }   but, if model function contains errors, never result shows up, there error page instead of it.
Comments
Post a Comment