php - Codeigniter set_value undefined variable -


i have code in ci controller:

if ($this->form_validation->run() === false)         {             $data['category'] = $this->categories_model->get_categories($id);             $this->load->view("templates/admin_header", $data);             $this->load->view("categories/edit", $data);             $this->load->view("templates/admin_footer", $data);          }         else         {             $array = array('id'=>$id, 'category_name' => $this->input->post('category_name'));              $this->categories_model->update($array);             $this->load->view("templates/admin_header");             $this->load->view("categories/edit");             $this->load->view("templates/admin_footer");         } 

and in view have this:

<input type="text" class="text" name="category_name" value="<?php echo set_value('category_name', $category['category_name']); ?>"/> 

when load view first time, gets category_name value database , displays in input field. when post form, updates database, when view loads after post, shows me error:

severity: notice message: undefined variable: category

and breaks html of input field.

if ($this->form_validation->run()) {     $array = array('id'=>$id, 'category_name' => $this->input->post('category_name'));      $this->categories_model->update($array);         }  $data['category'] = $this->categories_model->get_categories($id);    $this->load->view("templates/admin_header", $data); $this->load->view("categories/edit"); $this->load->view("templates/admin_footer"); 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -