Skip to Content
PHPCODE
CodeIgniter Fetch Article for Edit
codeigniter code / August 2, 2018

Fetch Article for Edit

step 1 :- create file articlesmodel.php in model

public function find_article($article_id)
{
$q=$this->db->select([‘id’,’title’,’body’])
->where(‘id’,$article_id)
->get(‘articles’);
return $q->row();
}

step 2 : create function in controller
public function edit_article($article_id)
{
$this->load->model(‘articlesmodel’,’articles’);
$article=$this->articles->find_article($article_id);
print_r($article);
}

PHPCODE © 2024