I have to fetch single Data From Database and display it in text box in Codeigniter.Please check the code and assist me where am i wrong?
 
 
Controller 
 
public function update_retrive()
{
$id = $this->uri->segment(3);
$this->load->model("model_add_user");
$d=$this->model_add_user->update_retrive($id);
$data['posts'] = $d;
}
Model 
 
public function update_retrive($userId)
{
$this->db->where('userId',$userId);
$this->db->from('add_user');
$q = $this->db->get();
return $q;
}
 
 
View 
 
foreach ($posts->result() as $post)
{
?>
 
 
 
 
 
 

?>