Reputation: 121
Here I ant desired url like in php but how can I code this in codeigniter with controller, model, and view? someone has a code with this?
http://mysite.com/search?query=batman&cat=movie
My Controller
function index(){
//some code to get search query value
}
My Model
function getSearch(){
//some code to get search value
}
My View
<form action="http://mysite.com/search/'; ?>">
<input name="query" value="">
<input name="cat" value="">
<input type="submit">
</form>
I want also to retrieve the seesion in text field after submitting.
Upvotes: 0
Views: 898
Reputation: 600
<form action="http://mysite.com/search/" method="post">
use this to fetch the record
$query = $this->input->post('query');
$cat = $this->input->post('cat');
In order to retrieve the type text in to the text field, use set_value
e.g.
<input name="query" value="<?php set_value('cat') ?>">
<input name="cat" value="<?php set_value('query') ?>">
hope this helps!
Upvotes: 1