CodeIgniter Forums
How do I create a simple site search? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: How do I create a simple site search? (/thread-31180.html)



How do I create a simple site search? - El Forum - 06-09-2010

[eluser]design_shuffle[/eluser]
Hi,

I am building my first codeigniter app. The client wishes to have a search box in the header of the site. The idea being a user enters a query, hits enter, the whole db is queried and then the user is presented with a results page with clickable items.

I have looked through the CI forum, wiki and user guide but cannot find a suitable answer. Is this possible?, if so could someone please point me in the right direction.

If this isn't possible, could someone suggest an alternative approach?


Thanks
Dan


How do I create a simple site search? - El Forum - 06-09-2010

[eluser]mddd[/eluser]
Of course it is possible. But the solution depens very much on what kinds of information you are storing in the site. You'll have to create a query (or multiple queries) that look for the specified word in all the relevant tables and fields. And then, you'll probably want to format the results in different formats. For instance, if information is found in a news post, you'll want to show some text from that post and provide a link to it; if information is found in the list of branches for your company, you'll show the branche address in the search results..

So: first think of which tables and fields are relevant; search in them; present the results in a logical manner.


How do I create a simple site search? - El Forum - 06-09-2010

[eluser]design_shuffle[/eluser]
Thanks for the reply.

The client sells chemicals, in some tables there are thousands of records and about 10 tables in total.

I am quite a novice programmer, do you know where I could find any tutorials/examples showing how to create such a controller?

Thanks


How do I create a simple site search? - El Forum - 06-10-2010

[eluser]FrancoNoronha[/eluser]
Dude... i found this site... it may help you!
Search CI App


How do I create a simple site search? - El Forum - 06-10-2010

[eluser]LuckyFella73[/eluser]
I think the hardest part with this is to create a good database structure.
All the pages the user may found in a result list have to be stored in db
and you have to build a system where you can link to the pages from result list.

If you are just searching in a area of the site - for example you have a news list
and get the detail view when clicking at a row then a search function is quite
easy. But when you want to search through the whole site and it have to be
possible to find every page that exists then it gets a bit harder ..


How do I create a simple site search? - El Forum - 06-24-2010

[eluser]design_shuffle[/eluser]
[quote author="FrancoNoronha" date="1276204589"]Dude... i found this site... it may help you!
Search CI App[/quote]

Thanks for this!