Jump to content

Trying to get property of non-object


yuanven

Recommended Posts

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!

tryingtogetpropertyofnonobject.png

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.