> if ($search_in == "1"){
>    $query1 = "SELECT * FROM FISH where  ID LIKE '%$search_text%'
> OR name LIKE '%$search_text%' OR Category LIKE '%$search_text%' OR Color
> LIKE '%$search_text%' OR Size LIKE '%$search_text%'";
> }

Looks good the way it is for now.
Things you *could* do:

1) Break up your query like this:
$query1 = "select * from fish ";
$query1 .= " where id like '%$search_text%' ";
$query1 .= "    or name like '%$search_text%' ";
.
.
.

2) Calculate a "score" for your search:
$query1 = "select *, ";
$query1 .= " (   id like '%$search_text%' ";
$query1 .= "   + name like '%$search_text%' ";
$query1 .= "   + category like '%$search_text%' ";
.
.
.
$query1 .= " ) as score ";
$query1 .= " where score > 0 ";
$query1 .= " order by score desc ";

So, here, a record gets a "point" for each match, and we add all the
"points" up as a "score" and now you have not only all the matches, but you
have a "score" for each to say how *good* the match is.

You could even give more "weight" to the name field by using:

$query1 .= "    + 3*(name like '%$search_text%') ";

Here, a "match" in the name field is 3X as important as in the category
field.

You could also try to build an "advanced search" form where users would pick
which fields to search in.

--
Visit the Zend Store at http://www.zend.com/store/
Wanna help me out?  Like Music?  Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to