[PHP] Multi-Word Searches
I'm putting together a PHP/MySQL search and have run into a minor problem. I have a text field to fill in a keyword on one page and that brings up another PHP page .com/showkey.php?id=divisionsearch=Bob%20Cobb. Within that new page, you can sort the results by ID, and to do this I made the hyperlink go to, for example, showkey.php3?id=projectsearch=$search. When I do this, however, it shortens the $search variable from Bob Cobb or Bob%20Cobb to just Bob. Can anyone help? Thanks Dave ?php $db = mysql_connect(localhost, webmstr); mysql_select_db(contracts,$db); $result = mysql_query(SELECT * FROM contracts WHERE project = '$search' OR agency = '$search' OR location = '$search' OR description = '$search' OR account = '$search' OR contact = '$search' OR division = '$search' ORDER BY $id,$db); echo table width=750 border=1 cellspacing=0 cellpadding=1\n; echo trtd width=255bfont face=arial size=2 a href=showkey.php3?id=projectsearch=$searchProject Title/a/td td width=50bfont face=arial size=2a href=showkey.php3?id=statussearch=$search.. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Multi-Word Searches
Dave: On Tue, Jul 02, 2002 at 09:13:00AM -0400, Dave Rosenberg wrote: .com/showkey.php?id=divisionsearch=Bob%20Cobb. Within that new page, you can sort the results by ID, and to do this I made the hyperlink go to, for example, showkey.php3?id=projectsearch=$search. When I do this, however, it shortens the $search variable from Bob ... snip ... echo trtd width=255bfont face=arial size=2 a href=showkey.php3?id=projectsearch=$search Before echoing out the search string into the new uri, do this: $search = urlencode($search); Please read http://www.php.net/manual/en/function.urlencode.php to make sure you understand the nuances with this. Enjoy, --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php