[eluser]Unknown[/eluser]
Hello , i have page which view all records from database on link :
http://localhost/databox/index.php/adminme/news
and i have made controller,model and view to show a specific record information in a form and if user want to edit any value he can by click submit on that form on the link:
http://localhost/databox/index.php/adminme/news/edit/$id
,but its not working !!
controller/news/
================
Code:
function edit()
{
$id = $this->uri->segment(4);
$this->load->model('adminme/news_model');
$data['results'] = $this->news_model->get_record($id);
//to make the $data variable public to news view
$this->load->vars($data);
$content['main_content'] = 'adminme/edit';
$ndata = array(
'News_title' => $this->input->post('News_title'),
'News_abstract' => $this->input->post('News_abstract'),
'News_discr' => $this->input->post('News_discr'),
'News_friendly_url' => $this->input->post('News_friendly_url'),
'News_date' => $this->input->post('News_date'),
'News_published' => $this->input->post('News_published')
);
$post=$this->input->post();
if(isset($post['News_title']))
{
$this->load->model('adminme/news_model');
$this->news_model->update_record($id,$ndata);
$this->index();
}
else {
echo "BAD NEWS!! ";
$this->load->view('adminme/includes/template',$content);
}
Model Code/news_model/
======================
Code:
function get_record($id) // RETRIEVE Specific RECORD Date
{
$query = $this->db->get_where('news', array('News_id' => $id));
return $query->result();
}
function update_record($id,$ndata)
{
$this->db->where('News_id', $id);
$this->db->update('news', $ndata);
}
so what i want is when clicking on link like:
http://localhost/databox/index.php/adminme/news/edit/85
show a new page contain a form with Record ID 85 values , user can change this values then click submit to change the record on database.
any help is appreciated .
thank you.