Re: [PHP-DB] keyword searching

2003-11-12 Thread Adam Williams
This is my SQL query:

SELECT seriesno, governor, descr, boxno, year, eyear, docno
from rg2 WHERE seriesno = '$_POST[seriesno]' and governor matches 
'*$searchterm*' or descr matches '*$searchterm*';

So as you can see, its gonna need some work to make it do fulltext 
searching of the descr field.  I'm not really sure how to make it do a 
keyword search, either since holmes*north*carolina doesn't work 
because it only searches  for those words in that order, if descr field 
in the database contains north carolina holmes it won't return that 
result, but I want it to because the person using the db is looking for 
all the fields that contain holmes, north, and carolina.

CPT John W. Holmes wrote:
From: Adam Williams [EMAIL PROTECTED]

CPT John W. Holmes wrote:

From: Adam Williams [EMAIL PROTECTED]

I am selecting a field in a database called description for keyword
searching.  The field contains names of people, states, years, etc.
When

someone searches for say holmes north carolina the query searches for
exactly that, fields which have holmes north carolina, and not fields
that contaim holmes, north, and carolina.  So I run a str_replace to
replace all spaces with *, which turns it into holmes*north*carolina,
but say that north carolina is before holmes in the field, it won't
return

those fields (it only returns fields in which holmes is infront of north
carolina).  So how can I have it return all fields which contain all
the words holmes, north, and carolina in any order, in that field?
Are you doing a fulltext search or just matching a word in a lookup
column?

I'm doing a fulltext search.


What is your query? Assuming MySQL, I get a result like this:

mysql select * from test where match(t) against ('holmes north carolina');
++
| t  |
++
| my name is john holmes from north carolina |
| i'm from the north |
| in carolina is my home |
| did I mention my last name is holmes?  |
++
4 rows in set (0.01 sec)
Isn't that what you want?

---John Holmes...

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


Re: [PHP-DB] keyword searching

2003-11-12 Thread CPT John W. Holmes
From: Adam Williams [EMAIL PROTECTED]

 This is my SQL query:

 SELECT seriesno, governor, descr, boxno, year, eyear, docno
 from rg2 WHERE seriesno = '$_POST[seriesno]' and governor matches
 '*$searchterm*' or descr matches '*$searchterm*';

Looks like you're doing the equivilent to a MySQL LIKE search, i.e.
looking for a pattern in a string instead of doing a FULLTEXT search.

Consult you're documentation, as I don't think the PHP list can be much more
help.

---John Holmes...

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



[PHP-DB] keyword searching

2003-11-12 Thread Adam Williams
Hello,

I am selecting a field in a database called description for keyword 
searching.  The field contains names of people, states, years, etc.  When 
someone searches for say holmes north carolina the query searches for 
exactly that, fields which have holmes north carolina, and not fields 
that contaim holmes, north, and carolina.  So I run a str_replace to 
replace all spaces with *, which turns it into holmes*north*carolina, 
but say that north carolina is before holmes in the field, it won't return 
those fields (it only returns fields in which holmes is infront of north 
carolina).  So how can I have it return all fields which contain all 
the words holmes, north, and carolina in any order, in that field?

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



RE: [PHP-DB] keyword searching

2003-11-12 Thread Robert Sossomon
Explode the kewords list.  I have mine explode the keyword and search
the description field.  It CAN limit it by category AND/OR by Vendor.
But this will do the trick without the limiters.

$keyword = $_POST[keyword];
$keywords = explode( , $keyword);
// so you can search for each word they enter
if ($category == ) {
$category = '%';
}

if ($vendor == ) {
$vendor = '%';
}
$query = select * from DATABASE where vendor like '$vendor' AND
cat_code like '$category';
// set up the part of the query that will always be the same
if (!$keywords) {
$keywords = '%';
//in case they don't enter any text
} else {
for ($i = 0; $i  count($keywords); $i++) {
$query .=  AND description like '%$keywords[$i]%';
//modify the query to search for each word they enter
}
}
$query .=  order by item_num asc;
// to sort alphabetically
$result = mysql_query($query);

/* Determine the number of records returned */
while ($row = MYSQL_FETCH_ROW($result))
$number = mysql_numrows($result);

if (!$number)
{
print(There are no results that match your querybr);
}
else
{
/* Print the relevant information */
$i = 0;
 
print  table cellspacing=\0\ cellpadding=\5\
border=\1\;

while ($i  $number)
{
$item_id = mysql_result($result, $i,id);
$item_name = mysql_result($result, $i,item_num);
$item_desc = mysql_result($result, $i,description);

if ($i%2 == 0)
{
print tr
bgcolor=\#ee\tdWhat do you want done with the data/tdtr\n;
}
else
{
print tr
bgcolor=\#ff\tdWhat do you want done with the data/tdtr\n;
}
$i++;
}
print /table;
}

/* Close the database connection */
MYSQL_CLOSE();
?

/body
/html

~~~
Love and you will be loved, and you will be able to do all that you
could not do unloved.

-Marques de Santillana. 
~~~

-Original Message-
From: Adam Williams [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, November 12, 2003 12:50 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: [PHP-DB] keyword searching


Hello,

I am selecting a field in a database called description for keyword 
searching.  The field contains names of people, states, years, etc.
When 
someone searches for say holmes north carolina the query searches for 
exactly that, fields which have holmes north carolina, and not fields 
that contaim holmes, north, and carolina.  So I run a str_replace to 
replace all spaces with *, which turns it into holmes*north*carolina, 
but say that north carolina is before holmes in the field, it won't
return 
those fields (it only returns fields in which holmes is infront of north

carolina).  So how can I have it return all fields which contain all 
the words holmes, north, and carolina in any order, in that field?

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

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