Postingan lainnya
Kelas Premium!
Belajar bikin website dari nol sekarang
Gunakan kupon "lebihcepat" untuk diskon 25%!
Tidak bisa get data - trying to get property of non-object
Ketika saya mau edit data dari halaman list, data yang mau saya edit tidak muncul malah muncul eror Trying to get property of non-object. saya sudah get data nya padahal. berikut saya lampirkan code dari model view dan kontrollernya- mohon bantuannya terima kasih...
// code controller
//edit outlet
public function edit($id_toko)
{
$toko_kami = $this->toko_kami_model->listing();
$data_toko_kami = count($toko_kami);
$pengguna = $this->pengguna_model->listing();
$data_pengguna = count($pengguna);
//validaasi input
$valid = $this->form_validation;
$valid->set_rules('nama_toko','Nama Outlet','required',
array( 'required' => '%s Harus Diisi'));
if($valid->run()=== FALSE){
//end validaasi
$data = array( 'title' => 'Edit Outlet',
'id_toko' => 'id_toko',
'toko_kami' => $toko_kami,
'data_toko_kami' => $data_toko_kami,
'data_pengguna' => $data_pengguna,
'isi' => 'admin/toko_kami/edit'
);
$this->load->view('admin/layout/wrapper', $data, FALSE);
//start masuk ddatabase
}else{
$i = $this->input;
$data = array( 'id_toko' => $id_toko,
'lokasi_toko' => $i->post('lokasi_toko'),
'nama_toko' => $i->post('nama_toko'),
'alamat_toko' => $i->post('alamat_toko'),
'urutan_toko' => $i->post('urutan_toko')
);
$this->toko_kami_model->edit($data);
$this->session->set_flashdata('sukses', 'Data Outlet Berhasil Diedit');
redirect(base_url('backend/toko_kami'),'refresh');
}
//end masuk database
}
//code model
// listing data cabang toko
public function listing()
{
$this->db->select('*');
$this->db->from('tbl_toko_kami');
$this->db->order_by('id_toko', 'desc');
$query = $this->db->get();
return $query->result();
}
// detail data outlet
public function detail($id_toko)
{
$this->db->select('*');
$this->db->from('tbl_toko_kami');
//where
$this->db->where('id_toko', $id_toko);
$this->db->order_by('id_toko', 'desc');
$query = $this->db->get();
return $query->row();
}
//code view list
<p>
<a href="<?php echo base_url('backend/toko_kami/tambah')?>" class="btn btn-success btn-lg">
<i class="fa fa-plus"></i> Tambah Data</a>
</p>
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th>NO</th>
<th>KOTA</th>
<th>NAMA OUTLET</th>
<th>ALAMAT</th>
<th>URUTAN</th>
<th>ACTION</th>
</tr>
</thead>
<tbody>
<?php $i = 1; foreach($toko_kami as $toko_kami) { ?>
<tr>
<td><?php echo $i ?></td>
<td><?php echo $toko_kami->lokasi_toko ?></td>
<td><?php echo $toko_kami->nama_toko ?></td>
<td width="300px" align="justify"><?php echo $toko_kami->alamat_toko ?></td>
<td><?php echo $toko_kami->urutan_toko ?></td>
<td>
<a href="<?php echo base_url('backend/toko_kami/edit/'.$toko_kami->id_toko) ?>" class="btn btn-warning btn-xs"><i class="fa fa-edit"></i> Edit</a>
<a href="<?php echo base_url('backend/toko_kami/delete/'.$toko_kami->id_toko) ?>" class="btn btn-danger btn-xs" onclick="return confirm('Yakin Menghapus Data ini?')"><i class="fa fa-trash-o"></i> hapus</a>
</td>
</tr>
</tbody>
<?php $i++; } ?>
</table>
<!-- /.box-body -->
// code views edit halaman
<?php
// Error input trigger alert
echo validation_errors('<div class="alert alert-warning">','</div>');
// form open
echo form_open(base_url('admin/suplier/edit/'.$toko_kami->$id_toko));
?>
<div class="col-md-5">
<div class="form-group">
<label>Nama Outlet</label>
<input type="text" name="nama_toko" class="form-control" placeholder="Masukan Nama Toko" value="<?php echo $toko_kami->nama_toko ?>" required>
</div>
</div>
<div class="col-md-5">
<div class="form-group">
<label>Lokasi Kota Outlet</label>
<input type="text" name="lokasi_toko" class="form-control" placeholder="Lokasi Kota Toko" value="<?php echo $toko_kami->lokasi_toko ?>" required>
</div>
</div>
<div class="col-md-2">
<div class="form-group">
<label>Urutan</label>
<input type="text" name="urutan_toko" class="form-control" placeholder="Urutan" value="<?php echo $toko_kami->urutan_toko ?>" required>
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<label>Alamat Lengkap</label>
<textarea type="input" name="alamat_toko" class="form-control" rows="5" value="" required><?php echo $toko_kami->alamat_toko ?></textarea>
</div>
</div>
<di class="form-group">
<button type="submit" class="btn btn-success btn-lg">
<i class="fa fa-save"> Edit Data</i>
</button>
<button type="reset" class="btn btn-default btn-lg">
<i class="fa fa-times"> Reset</i>
</button>
</di>
</div>
<?php
// form close
echo form_close();
?>
0