[eluser]Awais Qarni[/eluser]
Hello I am new to codeigniter. I am learning this framework by developing a testing application. I am showing user listing and in front of each record an anchor tag to edit that record.
That anchor tag looks like
Code:
echo(anchor('first/edit_user/'.$value->id,'Edit'));
It redirects the browser to first controller and edit_user function. At edit_user function I load the view of edit like this.
Code:
$this->load->view('edit_user',$data);
. It loads the view with respect to selected record to edit the record and the url looks like
Code:
http://localhost/CodeIgniter/index.php/first/edit_user/9
. Every thing works fine. But when user clicks the update button it again comes to same function. It updates record and then again tries to load the same view but here a problem occurs. Now after updating record it loads the view and url becomes like this
Code:
http://localhost/CodeIgniter/index.php/first/edit_user
. It creates error as it is not having the id of the selected record. IF i change the load view code of my function like this
Code:
$this->load->view('edit_user/'$this->uri->segment(3)),$data);
. It generates an error of edit_user/.php is not defined and some thing like that.
Now I want to ask How can I Redirect the user to same edit form telling that his record has been updated? How to load the view of selected record from function of the controller?