Welcome Guest, Not a member yet? Register   Sign In
How to Edit data? Simple question
#1

Hello everyone! I have a simple question about editing data in CI.

I have a simple view, with link to edit a record, like this:


PHP Code:
<?php echo site_url("edit/person/".$item['id']) ;?>


where 'id' is user ID in a database.

On this View, I have a form:


PHP Code:
<?php echo form_open('edit/person'); ?>



There is my Edit method:
PHP Code:
public function person($id=NULL)
 
   {
 
       $this->form_validation->set_rules('username''User Name''required');

 
           if ($this->form_validation->run() === FALSE) {
 
               
                $data
['person'] = $this->table_model->get_person($id);
 
               $this->load->helper('url');
 
               $this->load->view('template/header');
 
               $this->load->view('detail'$data);
 
               $this->load->view('template/footer');
 
           }
 
           else
            
{
 
               $data['message']='All changes saved';
 
               $this->table_model->person_edit();
 
               $this->load->view('template/header');
 
               $this->load->view('success',$data);
 
               $this->load->view('template/footer');
 
           }
 
       


And my model has 'person_edit()' method. This code is working fine and updates the data, but if I try to submit form with blank 'username' field, I get an error because 
PHP Code:
$this->load->view('detail'$data); 


in my Edit method doesn't have parameter for ID.

How can I put the GET ID  parameter in a load-view? thanks

Sorry for a noob question...
Reply


Messages In This Thread
How to Edit data? Simple question - by Razzer - 01-06-2019, 07:52 AM
RE: How to Edit data? Simple question - by Razzer - 01-06-2019, 10:39 AM
RE: How to Edit data? Simple question - by Razzer - 01-06-2019, 09:32 PM



Theme © iAndrew 2016 - Forum software by © MyBB