I am using codeigniter-3 framework for developing web application, i have one update form when ever i click on any particular record it's taking an ID of that particular record and passing to the URL this part is working fine,now i want instead of taking id i want to take all the record data and passed to the controller instead of the url parameters can you give me some idea how to do this one ..?
like this i am taking the id of particular tank but now i want entire object or array of that particular record and passing to the controller instead of the URL parameters.
<a href="<?php echo base_url(); ?>book/edit_book?book_id=<?php echo $book['book_id']; ?>">Update</a>
controller.php
$book_id = $this->input->get('book_id',TRUE);
$url = 'http://local.com/books?book_id='.$book_id;
//rest of my logic based on the URL
CodePudding user response:
Yes, there is a way to set id via session instead of url, to set user_id can do it like this
$this->session->set_userdata('book_id', $book_id);
Then you can retrive data session like this
$this->session->userdata('book_id')
For more detail how to use session you can go to this link
CodePudding user response:
In your view set id in url segment.
<a href="<?php echo base_url(); ?>book/edit_book/<?php echo $book['book_id']; ?>">Update</a>
In your controller ,receive the value passed through link by uri class.
Controller :
$book_id = $this->uri->segment(3);
$url = 'http://local.com/books?book_id='.$book_id;