Re: confused about logic

From: Date: Fri, 19 Mar 2004 16:28:21 +0000
Subject: Re: confused about logic
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-180976@lists.php.net to get a copy of this message
From: "Aaron Wolski" <aaronjw@martekbiz.com> > I have input for where users can enter order numbers in which to search > the database to find results matching their entry. > > To enter multiple order numbers they can comma separate like: > 1,34,21,34,54 > > What I need to do is take those numbers and make a query that would like > like: > > (cart_id in('1','34','21','34','54') OR id > in('1','34','21','34','54')) Why do you need to put quotes around integers?? $var = '1,34,21,34,54'; //replace comma with quote,comma,quote and add quotes to beginning and end $in_clause = "'" . str_replace(',',"','",$var) . "'"; $query = "WHERE (cart_id IN ($in_clause) OR id IN ($in_clause))"; ---John Holmes...

« previous php.general (#180976) next »