Re: How to search products on my site

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



At 08:54 AM 8/9/2005, virtualsoftware@xxxxxxxxx wrote:
Hi,

I have a site with some phone products. I want to search for a specific products. I use this:

SELECT product_id, product_name FROM products WHERE product_name LIKE '%$search_string%'

It works fine if the search string counts 1 word. But if the search string id counts 2 or 3 or more words it's not working.. How can i do this kind of search. I do not want a boolean search or a fulltext search.

Thabks for any help!


A lot of this depends on how your site is constructed and the kind of products you're offering.

split() the string, strip out any noise words, then use the array processing features of PHP to build the WHERE condition so you end up with WHERE product_name LIKE 'arrSearch[1]' OR product_name LIKE 'arrSeach[2]' ... and so forth

I think that would be deadly slow -- you're essentially abandoning any indexes and doing a sequential read of the database. If MySQL, does it have string search functions - InString() or InArray()

You might also reconsider your search criteria - offer a series of combo boxes from which user makes a selection. Then you can construct the query from the combo box choices.

If the database is MySQL, and you have general description fields, what's wrong with indexed text search? It's pretty fast.

Or abandon search altogether, and present groups of products, user clicks on a group which opens up the sub-group with more detailed choices - usually specific products. See http://www.leevalley.com . The advantage of this is it exposes the user to associated products.

By the way - how is a search not Boolean? Except for fairly sophisticated fuzzy logic applications you're either found something or not. (How about search with three levels? Teenage child - goes out, thrashes around, comes back with something close, or nothing; Father - more purposeful, but unless the item is where he last laid it down no hope of retrieval; Mother- here it is.)

Of semi-fuzzy - you asked for gray, but here's the same thing in a wonderful orange.

Cheers - Miles
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux