Jump to content

Text Search


coolphpdude

Recommended Posts

Hi,

 

I need help on a project. Ive created a database where you upload details on a holiday (location, hotel, features of the hotel, price, etc...), so there are quite alot of fields. On the website i want to give the user a basic search facility. I want the user to be able to enter a single word or combination of words to search for matches within my database. So for example...

 

if i have got this record in my database:

Hotel: The Leazes

Rooms: 2

Description: Beautiful modern hotel with swimming pool and kids club.

 

If the user enters 'the leazes' it finds the hotel and displays the results, however, if the user searches for the word 'leazes' only then nothing is returned. Can any1 help with this?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/95592-text-search/
Share on other sites

Hi again, that hasn't worked for me. I'll copy my code in, the search variable is called $keyword

 


$holiday_result = mysql_query("SELECT * FROM holidays WHERE holiday_id='$keyword' OR holiday_hotel LIKE %'.$keyword.'% OR holiday_area='$keyword' OR holiday_location='$keyword' OR holiday_description='$keyword' OR holiday_price='$keyword' OR holiday_status='$keyword'",$db); 

 

The part of the search where it checks the holiday_hotel is the only part i have altered so far. The reason i have only altered this part of the code is because it is only the hotel that i am querying for test purposes the final search facility will do a 'LIKE' search within all fields.

 

Thanks again for your help

Link to comment
https://forums.phpfreaks.com/topic/95592-text-search/#findComment-489432
Share on other sites

should be

 

holiday_hotel LIKE '%".$keyword."%'

note the quotes

$holiday_result = mysql_query("SELECT * FROM holidays WHERE holiday_id='$keyword' OR holiday_hotel LIKE '%".$keyword."%' OR property_area='$keyword' OR property_city='$keyword' OR property_postcode='$keyword' OR property_price='$keyword' OR property_status='$keyword'",$db); 

Link to comment
https://forums.phpfreaks.com/topic/95592-text-search/#findComment-489435
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.