Welcome Guest, Not a member yet? Register   Sign In
Query string as second uri segment
#1

[eluser]vertmonkee[/eluser]
Is it possible to have the second uri segment as a query string variable?

For example a search URL could be

mysite.com/search/what-has-been-searched-for
#2

[eluser]jayapalchandran[/eluser]
in the routes.php you can add this at the bottom

$route['search/(:any)']='search/Index/$1';

and

in the controller Search.php

function Index($qs=NULL)
{
if(is_null($qs)
//Fresh request. Form is not submitted
else // form has been submitted. do the db query with the search string.
}

what i am doing here is when you load the search page then no extra parameters are send so the search form will load...

if you have provided any search string (i assume that you append the search result in the url) then $qs will be having the string with which you can do some process and display the search results...

if you did not understand then please post a detailed question.




Theme © iAndrew 2016 - Forum software by © MyBB