php - form editing with codeigniter -


i'm trying edit form field codeigniter. submitted values first shown view , informations edited. when submit form following error occurs

a php error encountered

severity: notice

message: undefined offset: 0

filename: views/tupdate.php

line number: 46

in line 46 have

 <input type="hidden" name="id" value="<?php echo $info[0]->id  ?>"> 

my controller :

 function update($id = 0)  {    $data['info'] = $this->trainingupdate_model->getdata_by_id($id);     $this->load->view('tupdate', $data);  }   function super() {     $id=$this->input->post('id');     $data['title']=$this->input->post('title');     $data['training_description']=$this->input->post('training_description');      if ($this->trainingupdate_model->update($id, $data)==true)     {       $this->load->view('traing_update_success');     }     else     {       $this->load->view('s_unsuccess');     } } 

my model:

 function getdata_by_id($id = 0)  {     $this->db->where('id',$id);     $sql = $this->db->get('training');     return $sql->result();  }    function update($id,$data)  {    $this->db->where('id', $id);    $this->db->update('training', $data);     if ($this->db->affected_rows() == '1')    {      return true;    }    return false;  } 

and view:

 <form action="trainingupdate/super" method="post">     <input type="hidden" name="id" value="<?php echo $info[0]->id  ?>">    title name:<input type="text" name="id" value="<?php echo htmlspecialchars($info[0]->title) ?>">    title name: <textarea type="text" name="overview" value=""><?php echo $info[0]->training_description; ?></textarea>     <input type="submit" value="update"> </form> 

i'm getting why information in not updating , why getting error.

please help. thanks

for reason submitted values not getting trainingupdate/super() method, submitted data passed model. going same view page , giving error. can tell me why happening?? again.

if getting 1 row update record use row() method fetch record

model

function getdata_by_id($id = 0)  {     $this->db->where('id',$id);     $sql = $this->db->get('training');     //return $sql->result();     return $sql->row();  } 

view

 <input type="hidden" name="id" value="<?php echo $info->id  ?>"> 

Comments