Re: [PHP] PHP/MySQL Search Engine Query Question

2002-07-28 Thread Tech Support

Here is an idea



using this method "car" would match "car", "carwash", "scar", "scarred",
etc.
Since this result will contain the entire boy of text you could some more
matching or scoring for relevancy



I had that code from a previous working project. I copied it and changed
some var names to make it more clear. I did not test it in this format but
it is a good example and you could certainly improve it or build on it.

Jim Grill
Support
Web-1 Hosting
http://www.web-1hosting.net
- Original Message -
From: "Paul Maine" <[EMAIL PROTECTED]>
To: "PHP PHP" <[EMAIL PROTECTED]>
Sent: Saturday, July 27, 2002 9:31 PM
Subject: [PHP] PHP/MySQL Search Engine Query Question


> I am currently working on a website that is implemented using PHP and
MySQL.
>
> The site currently has a simple search engine that allows a shopper to
type
> in a search string that is stored in $search. For example, if a shopper
> types in 1972 Ford Mustang
> $string ="1972 Ford Mustang"
>
> Using the following SQL statement:
> SELECT * FROM whatevertable WHERE whatevercolumn LIKE '%$search%
>
> Records are returned that have this exact string and in this exact order
> (I'm aware a wild card character is included on the front and back of the
> string).
>
> My desire is to be able to logically AND each token of the search together
> independent or the order of the tokens.
> I want to return all records that have Mustang AND 1972 AND Ford.
>
> Since a shopper inputs the search string in advance I don't know how many
> tokens will be used.
>
> I would appreciate any suggestions.
>
> Regards,
> Paul
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>



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




RE: [PHP] PHP/MySQL Search Engine Query Question

2002-07-27 Thread Naintara Jain

You can use explode/split functions on the search parameters - that will
give u an array with each search token indexed individually. Suppose the
search input was 'abc xyz'

$strsearch = "abc xyz";

$search=explode(" ",$strsearch);

your array "search" will contain

$search[0]=abc
$search[1]=xyz

Now, you can iterate through the array members and create a SQL string out
of it, join the elements with "LIKE" and "AND".

so that you have something like

SELECT * FROM whatevertable WHERE whatevercolumn LIKE '%$search[0]% AND
whatevercolumn LIKE '%$search[1]%

Since you won't know how many search input 'tokens' will be searched on: Use
a loop to create the SQL statement. You can also use the implode() function
to create the SQL.

Textual searches can be optimised somewhat by creating the appropriate
indexes (refer to the MySQL manual).

-Naintara

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
t]On Behalf Of Paul Maine
Sent: Sunday, July 28, 2002 8:02 AM
To: PHP PHP
Subject: [PHP] PHP/MySQL Search Engine Query Question


I am currently working on a website that is implemented using PHP and MySQL.

The site currently has a simple search engine that allows a shopper to type
in a search string that is stored in $search. For example, if a shopper
types in 1972 Ford Mustang
$string ="1972 Ford Mustang"

Using the following SQL statement:
SELECT * FROM whatevertable WHERE whatevercolumn LIKE '%$search%

Records are returned that have this exact string and in this exact order
(I'm aware a wild card character is included on the front and back of the
string).

My desire is to be able to logically AND each token of the search together
independent or the order of the tokens.
I want to return all records that have Mustang AND 1972 AND Ford.

Since a shopper inputs the search string in advance I don't know how many
tokens will be used.

I would appreciate any suggestions.

Regards,
Paul


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





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




[PHP] PHP/MySQL Search Engine Query Question

2002-07-27 Thread Paul Maine

I am currently working on a website that is implemented using PHP and MySQL.

The site currently has a simple search engine that allows a shopper to type
in a search string that is stored in $search. For example, if a shopper
types in 1972 Ford Mustang
$string ="1972 Ford Mustang"

Using the following SQL statement:
SELECT * FROM whatevertable WHERE whatevercolumn LIKE '%$search%

Records are returned that have this exact string and in this exact order
(I'm aware a wild card character is included on the front and back of the
string).

My desire is to be able to logically AND each token of the search together
independent or the order of the tokens.
I want to return all records that have Mustang AND 1972 AND Ford.

Since a shopper inputs the search string in advance I don't know how many
tokens will be used.

I would appreciate any suggestions.

Regards,
Paul


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