FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Search Script





chatrack
Hi,

I have a lot of data in Mysql table. I like to get 5 to 10 best search results, based on keyword(s).

exact matching may some time make less search results.

Can you suggest any php/mysql script that can search out mysql database in
near matching with user's query keyword/s
sonam
I am not at home now but with % you can give mysql search command to find everything what contain some word or part of word.


Code:
$query = "select * from sometable WHERE text like %time%";


This will find: sometimes, timeless, etc...

Sonam
macky
i deal with the same issue. but the difference is that the keyword i am looking for want to match on other fields i specify. the logic was like match the keyword on the list of field names i preferred to search in.

it almost like :

Code:

SELECT * FROM table1 WHERE {list of field names here} LIKE %keyword%;


one of my friends suggested me that use a foreach loop that contains a set of array field names which i think will work great

but i haven't heard a pure SQL statement that will satisfy my needs.
jmraker
mysql can do search engine like queries on text and return a floating point number on every record based on how well it matches the search string by adding a fulltext index to the fields you're searching on. The larger the index the more time it'll take for mysql to run the query.

Code:

// Search for records that contain mysql but not php
SELECT *, MATCH(record_title, record_html) AGAINST("mysql -php"  IN BOOLEAN MODE) as score FROM record WHERE MATCH(record_title, record_html) AGAINST("mysql -php"  IN BOOLEAN MODE) ORDER BY score DESC LIMIT 10


http://devzone.zend.com/article/1304
macky
i like the approach of jmraker. but the problem with that approach is that you need to set the fields as fulltext first and it only works in char, varchar and texts... how about if i have a large site about recruitment system that mostly people tend to search the most relevant keywords like, the salary, height, dates and etc... then it will be hard enough to do such a query again for those numbers input by users although im not really sure how it works...
chatrack
Hi,

Is there a script in php to do the same ?
han007
see this
http://www.coderbari.com/shaifulonline.com/Download/Crawler.zip
it is web Crawler and you can change it for your self.
Related topics
Search function
MySql issues
PHP - checking lengths
AJAX tutorial [2nd part now updated]
search script.
Creating a Search Script with PHP for MySQL
Search Script
Highlighting Search Terms
sick of the old boring Tree system for everything(like CMS)
Blog Search
What is Google doing?
Make me a search script !!! For loads of Frih$'s !
Will work for FRIH$
Search Script..?
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.