RE: [PHP-DB] More problems with searching

From: Date: Thu, 01 Jul 2004 18:54:34 +0000
Subject: RE: [PHP-DB] More problems with searching
Groups: php.db 
Request: Send a blank email to php-db+get-35084@lists.php.net to get a copy of this message
On 01 July 2004 18:36, Justin Patrin wrote: > On Thu, 1 Jul 2004 12:28:46 -0500, Shiloh Madsen > <shiloh_madsen@nsc-support.com> wrote: > > > > After the very kind help i was given last night I have the query > > being built right, however the query does not work. Just to > > refresh, the gentlemen who had helped me suggested creation of a > > query that looks like: > > > > SELECT * FROM table1 where 1 or cat or dog...and so forth. Now, > > this query is building fine, but the where 1 is causing it to > > return rows even if it has none of the search terms. When i run it > > in sql without the where 1 it works as it should, but with that, i > > get all rows returned. Is there a way i can reword this query or am > > I doing something wrong? > > > > this was Mr Holmes's solution (in part): > > $query = "SELECT * FROM keyword WHERE 1 " > > $words = explode(' ',$_GET['search_text']); > > foreach($words as $word) > > { $query .= " AND keyword = '$word' "; } > > Shouldn't that be OR? ... and, if it should, that should be a 0 instead of a 1 (although I'm not a huge fan of this technique!). Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Headingley Campus, LEEDS, LS6 3QS, United Kingdom Email: m.ford@leedsmet.ac.uk Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211

« previous php.db (#35084) next »