[PHP-DB] Search tutroial

2002-04-24 Thread Jennifer Downey

Hi all,

Would someone kindly point me to a tutorial on designing a search script for
mysql db.
I have tried to build one but can't get anywhere with it.

Thanks
Jennifer

--
The sleeper has awaken


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.351 / Virus Database: 197 - Release Date: 4/19/2002



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




Re: [PHP-DB] Search tutroial

2002-04-24 Thread Dan Swensen

Getting a search function running perplexed me, too, until I looked at the 
MySQL docs. With the Full-Text Search function I got a search function 
working in minutes. 

http://www.mysql.com/doc/F/u/Fulltext_Search.html

Watch out for the weird bug that ignores duplicate rows, though. It can make 
for zero returns in small databases for no logical reason. That drove me nuts 
until I figured out why it was happening. (It's mentioned at the bottom of 
the docs.) 


 Hi all,
 
 Would someone kindly point me to a tutorial on designing a search 
 script for mysql db. I have tried to build one but can't get 
 anywhere with it.
 
 Thanks
 Jennifer
 
 --
 The sleeper has awaken
 
 ---
 Outgoing mail is certified Virus Free.
 Checked by AVG anti-virus system (http://www.grisoft.com).
 Version: 6.0.351 / Virus Database: 197 - Release Date: 4/19/2002
 
 -- 
 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




Re: [PHP-DB] Search tutroial

2002-04-24 Thread Julie Meloni


JD Would someone kindly point me to a tutorial on designing a search script for
JD mysql db.
JD I have tried to build one but can't get anywhere with it.

Well, that would depend on what and how you are searching, your table
structure, etc.  Essentially, every SELECT query is a search.

If you post more information about your table(s) structure, your
search methods and the search parameters, people would probably be
able to help you.


- Julie

-- Julie Meloni
-- [EMAIL PROTECTED]
-- www.thickbook.com

Find Sams Teach Yourself MySQL in 24 Hours at
http://www.amazon.com/exec/obidos/ASIN/0672323494/thickbookcom-20


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




Re: [PHP-DB] Search tutroial

2002-04-24 Thread Jennifer Downey

This is basically what I am trying to do
if($search)
{
$query = SELECT uid, id, image, iname, quantity, type FROM
{$config[prefix]}_shop WHERE  iname = $shopsearch;
  $ret = mysql_query($query);
  while(list($quantity)=mysql_fetch_row($ret))

   $name = $row['user'];
   echo $name;

}else{

echo FORM METHOD=post ACTION='$PHP_SELF';
echo Search ShopsBRinput type=text name=\shopsearch\ value=\\;
echo BRINPUT TYPE='submit' NAME='search' VALUE='Search';

}

This is a dump of the table

uid int(10) NOT NULL default '0',
  id int(5) NOT NULL default '0',
  iname varchar(50) NOT NULL default '',
  image varchar(100) NOT NULL default '',
  quantity int(10) unsigned NOT NULL default '1',
  type varchar(20) NOT NULL default '',
  price int(6) NOT NULL default '0',
  user varchar(50) NOT NULL default '',
  KEY uid (uid)

Just a note this works throughout my site and I have no trouble with it:
{$config[prefix]}_shop
I'm not trying to be rude but I get sick of it when people tell me that this
is the problem when it has nothing to do with the question I am asking.

Thanks for your time and help
Jennifer

Julie Meloni [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...

 JD Would someone kindly point me to a tutorial on designing a search
script for
 JD mysql db.
 JD I have tried to build one but can't get anywhere with it.

 Well, that would depend on what and how you are searching, your table
 structure, etc.  Essentially, every SELECT query is a search.

 If you post more information about your table(s) structure, your
 search methods and the search parameters, people would probably be
 able to help you.


 - Julie

 -- Julie Meloni
 -- [EMAIL PROTECTED]
 -- www.thickbook.com

 Find Sams Teach Yourself MySQL in 24 Hours at
 http://www.amazon.com/exec/obidos/ASIN/0672323494/thickbookcom-20



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.351 / Virus Database: 197 - Release Date: 4/19/2002



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




Re: [PHP-DB] Search tutroial

2002-04-24 Thread Jennifer Downey

By the way SELECT uid, id, image, iname, quantity, type, user where it shows
below that user isn't in the query- it is there in my editor.
I just forgot to put it in before sending.
Jennifer
Jennifer Downey [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 This is basically what I am trying to do
 if($search)
 {
 $query = SELECT uid, id, image, iname, quantity, type FROM
 {$config[prefix]}_shop WHERE  iname = $shopsearch;
   $ret = mysql_query($query);
   while(list($quantity)=mysql_fetch_row($ret))

$name = $row['user'];
echo $name;

 }else{

 echo FORM METHOD=post ACTION='$PHP_SELF';
 echo Search ShopsBRinput type=text name=\shopsearch\ value=\\;
 echo BRINPUT TYPE='submit' NAME='search' VALUE='Search';

 }

 This is a dump of the table

 uid int(10) NOT NULL default '0',
   id int(5) NOT NULL default '0',
   iname varchar(50) NOT NULL default '',
   image varchar(100) NOT NULL default '',
   quantity int(10) unsigned NOT NULL default '1',
   type varchar(20) NOT NULL default '',
   price int(6) NOT NULL default '0',
   user varchar(50) NOT NULL default '',
   KEY uid (uid)

 Just a note this works throughout my site and I have no trouble with it:
 {$config[prefix]}_shop
 I'm not trying to be rude but I get sick of it when people tell me that
this
 is the problem when it has nothing to do with the question I am asking.

 Thanks for your time and help
 Jennifer

 Julie Meloni [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 
  JD Would someone kindly point me to a tutorial on designing a search
 script for
  JD mysql db.
  JD I have tried to build one but can't get anywhere with it.
 
  Well, that would depend on what and how you are searching, your table
  structure, etc.  Essentially, every SELECT query is a search.
 
  If you post more information about your table(s) structure, your
  search methods and the search parameters, people would probably be
  able to help you.
 
 
  - Julie
 
  -- Julie Meloni
  -- [EMAIL PROTECTED]
  -- www.thickbook.com
 
  Find Sams Teach Yourself MySQL in 24 Hours at
  http://www.amazon.com/exec/obidos/ASIN/0672323494/thickbookcom-20
 


 ---
 Outgoing mail is certified Virus Free.
 Checked by AVG anti-virus system (http://www.grisoft.com).
 Version: 6.0.351 / Virus Database: 197 - Release Date: 4/19/2002




---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.351 / Virus Database: 197 - Release Date: 4/19/2002



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




Re: [PHP-DB] Search tutroial

2002-04-24 Thread Dan Brunner

Hello!!

Use LIKE in your WHERE clause...

You can also more then when Field

Example.

$query = SELECT uid, id, image, iname, quantity, type FROM
{$config[prefix]}_shop WHERE  iname  LIKE = '%$shopsearch% ORDER BY 
iname';
   $ret = mysql_query($query);
   while(list($quantity)=mysql_fetch_row($ret))

Dan



On Wednesday, April 24, 2002, at 01:47 PM, [EMAIL PROTECTED] wrote:

 By the way SELECT uid, id, image, iname, quantity, type, user where it 
 shows
 below that user isn't in the query- it is there in my editor.
 I just forgot to put it in before sending.
 Jennifer
 Jennifer Downey [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 This is basically what I am trying to do
 if($search)
 {
 $query = SELECT uid, id, image, iname, quantity, type FROM
 {$config[prefix]}_shop WHERE  iname = $shopsearch;
   $ret = mysql_query($query);
   while(list($quantity)=mysql_fetch_row($ret))

$name = $row['user'];
echo $name;

 }else{

 echo FORM METHOD=post ACTION='$PHP_SELF';
 echo Search ShopsBRinput type=text name=\shopsearch\ 
 value=\\;
 echo BRINPUT TYPE='submit' NAME='search' VALUE='Search';

 }

 This is a dump of the table

 uid int(10) NOT NULL default '0',
   id int(5) NOT NULL default '0',
   iname varchar(50) NOT NULL default '',
   image varchar(100) NOT NULL default '',
   quantity int(10) unsigned NOT NULL default '1',
   type varchar(20) NOT NULL default '',
   price int(6) NOT NULL default '0',
   user varchar(50) NOT NULL default '',
   KEY uid (uid)

 Just a note this works throughout my site and I have no trouble with 
 it:
 {$config[prefix]}_shop
 I'm not trying to be rude but I get sick of it when people tell me that
 this
 is the problem when it has nothing to do with the question I am asking.

 Thanks for your time and help
 Jennifer

 Julie Meloni [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...

 JD Would someone kindly point me to a tutorial on designing a search
 script for
 JD mysql db.
 JD I have tried to build one but can't get anywhere with it.

 Well, that would depend on what and how you are searching, your table
 structure, etc.  Essentially, every SELECT query is a search.

 If you post more information about your table(s) structure, your
 search methods and the search parameters, people would probably be
 able to help you.


 - Julie

 -- Julie Meloni
 -- [EMAIL PROTECTED]
 -- www.thickbook.com

 Find Sams Teach Yourself MySQL in 24 Hours at
 http://www.amazon.com/exec/obidos/ASIN/0672323494/thickbookcom-20



 ---
 Outgoing mail is certified Virus Free.
 Checked by AVG anti-virus system (http://www.grisoft.com).
 Version: 6.0.351 / Virus Database: 197 - Release Date: 4/19/2002




 ---
 Outgoing mail is certified Virus Free.
 Checked by AVG anti-virus system (http://www.grisoft.com).
 Version: 6.0.351 / Virus Database: 197 - Release Date: 4/19/2002



 --
 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




Re[2]: [PHP-DB] Search tutroial

2002-04-24 Thread Julie Meloni

JD By the way SELECT uid, id, image, iname, quantity, type, user where it shows
JD below that user isn't in the query- it is there in my editor.
 $query = SELECT uid, id, image, iname, quantity, type FROM 
{$config[prefix]}_shop WHERE  iname = $shopsearch;

The first problem would be that your search string needs to be enclosed
in quotes, preferably single, or at the very least escaped double
quotes.

Presumably, you want to find things that are inexact matches, but darn
close, and in that case you can use LIKE in your query.  Look in the
MySQL manual for the various permutations of LIKE clauses.

But fundamentally, you should to throw in an or die(mysql_error()) in
conjunction with your mysql_query function.  IE:

$ret = mysql_query($query) or die(mysql_error());

This will tell you exactly the problem when executing a query. And as
others have said, another fine way to debug your queries is to simply
echo them to the screen, look at what is being sent to MySQL, and
trying it manually if the problem isn't glaringly obvious.

But first, surround your search term with quotes and see how far you
get.

- Julie

-- Julie Meloni
-- [EMAIL PROTECTED]
-- www.thickbook.com

Find Sams Teach Yourself MySQL in 24 Hours at
http://www.amazon.com/exec/obidos/ASIN/0672323494/thickbookcom-20


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