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

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -