yuanven Posted September 24, 2022 Share Posted September 24, 2022 Hello. Please help me because I can't get this done. This is where I input and go to controller function simpan_nilai <form method="post" action="<?php echo base_url('administrator/nilai/simpan_nilai'); ?>"> <table class="table table-striped table-hover table-bordered mt-4"> <tr> <td width="25px">NO</td> <td width="150px">NIM</td> <td>NAMA MAHASISWA</td> <td>NILAI</td> </tr> <?php $no = 1; foreach ($list_nilai as $row) : ?> <tr> <td><?php echo $no++ ?></td> <td><?php echo $row->nim; ?></td> <td><?php echo $row->nama_lengkap ?></td> <input type="hidden" name="id_krs[]" value="<?php $row->id_krs; ?>"> <td width="25px"><input type="text" name="nilai[]" class="form-control" value="<?php echo $row->nilai; ?>"></td> </tr> <?php endforeach; ?> </table> <button type="submit" class="btn btn-primary">Simpan</button> </form> This is function simpan_nilai and go to view daftar_nilai public function simpan_nilai() { $query = array(); $id_krs = $_POST['id_krs']; $nilai = $_POST['nilai']; for($i=0; $i>sizeof($id_krs); $i++) { $this->db->set('nilai', $nilai[$i])->where('id_krs',$id_krs[$i])->update('krs'); } $data = array( 'id_krs' => $id_krs ); $this->load->view('templates_administrator/header'); $this->load->view('templates_administrator/sidebar'); $this->load->view('administrator/daftar_nilai',$data); $this->load->view('templates_administrator/footer'); } This is view daftar_nilai <?php $nilai = get_instance(); $nilai->load->model('krs_model'); $nilai->load->model('mahasiswa_model'); $nilai->load->model('matakuliah_model'); $nilai->load->model('tahunakademik_model'); $krs = $nilai->krs_model->get_by_id($id_krs[0]); $kode_matakuliah = $krs->kode_matakuliah; $id_thn_ak = $krs->id_thn_ak; ?> <div class="container-fluid"> <div class="alert alert-success"> <i class="fas fa-university"></i> DAFTAR NILAI MAHASISWA </div> <table class="table table-hover table-bordered table-striped mt-3"> <tr> <td>NO</td> <td>NIM</td> <td>NAMA LENGKAP</td> <td> <?php $no = 1; for($i=0; $i<sizeof($id_krs); $i++) { ?> <tr> <td><?php echo $no++ ?></td> <?php $nim = $nilai->krs_model->get_by_id($id_krs[$i])->nim; ?> <td><?php echo $nim; ?></td> <td><?php echo $nilai->mahasiswa_model->get_by_id($nim)->nama_lengkap ?></td> <td><?php echo $nilai->krs_model->get_by_id($id_krs[$i])->nilai ?></td> </tr> <?php } ?> </td> </tr> </table> </div> And I get this error A PHP Error was encountered Severity: Notice Message: Trying to get property 'kode_matakuliah' of non-object Filename: administrator/daftar_nilai.php Line Number: 10 Backtrace: File: C:\xampp\htdocs\sisfo_akademikk\application\views\administrator\daftar_nilai.php Line: 10 Function: _error_handler File: C:\xampp\htdocs\sisfo_akademikk\application\controllers\administrator\nilai.php Line: 149 Function: view File: C:\xampp\htdocs\sisfo_akademikk\index.php Line: 315 Function: require_once Thankyou for your help! Quote Link to comment https://forums.phpfreaks.com/topic/315362-trying-to-get-property-of-non-object/ Share on other sites More sharing options...
mac_gyver Posted September 24, 2022 Share Posted September 24, 2022 the only thing that's apparent from the posted information is that $krs isn't an object. you can use var_dump($krs); to find out what it is, then work backwards to find why it isn't what you expect. Quote Link to comment https://forums.phpfreaks.com/topic/315362-trying-to-get-property-of-non-object/#findComment-1600993 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.