CodeIgniter Forums
How to Refine Search Results - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: How to Refine Search Results (/showthread.php?tid=24208)



How to Refine Search Results - El Forum - 11-03-2009

[eluser]Arun Kris[/eluser]
Hi All,

Iam having a web application in which after basic search the users should be able to filter the results he obtained using some filters.
For example let the user searched for a motor car. Then a list of motor cars will be displayed. Of these the user should be able to filter the cars based on certain criteria like color, place etc also the count of items under specific criteria should be displayed.

How can I implement this using code igniter


How to Refine Search Results - El Forum - 11-03-2009

[eluser]pistolPete[/eluser]
[quote author="Arun Kris" date="1257262955"]How can I implement this using code igniter[/quote]

The implementation heavily depends on your database layout, have you specified that yet?

BTW: You should really post what you got already, e.g. database layout, controller / model structure etc. I don't think anyone can / will give you a full featured ready-to-use application..


How to Refine Search Results - El Forum - 11-03-2009

[eluser]GIN[/eluser]
You can use $_GET in url, or you can make urls like /search/what/search_word/sort/name/color/red/ and in your controller you can parse this url into associate array
Code:
$s['what'] = 'search_word';
$s['sort'] = 'name';
$s['color'] = 'red';
etc.


How to Refine Search Results - El Forum - 11-03-2009

[eluser]Dam1an[/eluser]
I had to do this not so long ago for a hotel search site not so long ago, and what I ended up with is:
1. Have an array in the session for the filters you want to apply, such as city_id, type_id, max_price etc
2. When you want to get all the items that match the filters (hotels in my case) get all the hotel IDs into an array
3. Use this array as part of a WHERE IN clause for the first filter (city_id)
4. Repeat for all your other filters, refining this array of hotel IDs that match all the criteria
5. Get the relevant data for the remaining IDs and display it

Starting off with a base of 75000+ hotels and filters spanning several tables, it performs really well too Smile


How to Refine Search Results - El Forum - 11-03-2009

[eluser]wiredesignz[/eluser]
[quote author="Dam1an" date="1257267041"]I had to do this not so long ago for a hotel search site not so long ago...[/quote]
So I guess this was quite recently then.

Welcome back Dam1an.


How to Refine Search Results - El Forum - 11-03-2009

[eluser]Dam1an[/eluser]
[quote author="wiredesignz" date="1257267610"]
So I guess this was quite recently then.

Welcome back Dam1an.[/quote]

Thanks Smile
Although being busy was only part of the reason for my absence (Heck, I'm still busy)
The main reason being that, moving into my flat 4 months ago, I still don't have internet, so when I do have it, I always seem to have more important things to do