CodeIgniter Forums
How i can write search function in CI ? - 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 i can write search function in CI ? (/showthread.php?tid=20041)



How i can write search function in CI ? - El Forum - 06-25-2009

[eluser]aamiraziz[/eluser]
Respected Developers,

i' m working on Job Portal. i don't know how can i write search function to find jobs in database.

i need to retrieve records using keyword matching (job title), not the exact title of job.
how can i write the function ??

is there any sample search function ?? please provide it to me

thank you for support.


How i can write search function in CI ? - El Forum - 06-25-2009

[eluser]slowgary[/eluser]
Your job listings should have a relational table containing keywords, so:
Code:
jobs table
=====================
job_id
job_title
job_employer
job_salary


keywords table
=====================
job_id
keyword

Then you could use something like php's explode() function to create an array from the user's search string. Then just query for keywords that match any of the words. You may also want to look into something like mysql's SOUNDEX() for fuzzy matching, it may help you find matches even when users spell the word wrong.

Good luck.