I am a beginner in Codeigniter and using version 3 I am performing update operation so I have store data and now I have created a separate form for update and want to set this form inputs values that are stored in databases
My View (update.php)
```<div class="form-group">
<label for="exampleInputEmail1">Title</label>
<?php echo form_input(['name'=>'title', 'placeholder'=>'Enter title',
'class'=>'form-control col- md-5',
'value'=>set_value('title','$post->title')]);?>
</div>```
My COntroller
public function update($id)
{
$this->load->model('queries');
$postt=$this->queries->getSinglePosts($id);
$post=$postt->title;
$this->load->view('update',['post'=>$post]);
}
My Model
public function getSinglePosts($id) { $query=$this->db->get_where('tbl_posts',array('id'=>$id));
if ($query->num_rows() >0 ) {
return $query->row();
}
}
Because you've used set_value('title','$post->title')]);
in your view file, I think you should remove this line from your controller $post=$postt->title;
and you should pass the whole of $postt
variable to your view (make sure that the $postt
is not an array of objects).