Forum Moderators: coopster

Message Too Old, No Replies

Query to Search DB

looking for a property "name"

         

old_expat

1:50 am on Jul 24, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm starting to work on my own new project to create a site to review properties. I have access, from a variety of sources, to customer reviews. So the most obvious (to me) approach is to use a database .. with probably an average of 6 reviews on each of 900+ properties.

One of the fields will be the complete property name.

I see 2 ways for the user find reviews on a property.

-an alphabetical list of properties, each of which is a link with query
-a search box that generates a query

I see all sorts of problems with a search box. Wrong spellings, caps, spaces, periods, etc. And the fact that many properties can have a partial match.

"Miami Beach Motel"
"Miami Beach Strand Motel"
"Beach Strand Motel"

etc

Can someone suggest an approach that will work well for the user as well as being accurate?

I will be hiring someone to have a look at the database structure I come up with and to write a sample PHP query

nfs2

2:02 am on Jul 24, 2006 (gmt 0)

10+ Year Member



You could use the "LIKE" clause in mysql

$search = $_GET['search'];
$sql = mysql_query("SELECT * FROM table_hotels WHERE hotel_name LIKE %$search%");

So if someone searches "motel" it'll return all results with that word in it. If someone searches "miami motel" all results with that string will be returned, like "cheap miami motel" and "miami motel and restaurant"

Of course you'll want to clean it up to avoid sql injection.. lol