Re: loop during a mysql query

From: Date: Sun, 08 Oct 2000 12:48:19 +0000
Subject: Re: loop during a mysql query
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-19085@lists.php.net to get a copy of this message
Hi, $sqlString = "SELECT * FROM table WHERE describtion like 'linux'" for($i = 0; $i < count($array); $i++) $sqlString .= " AND describtion like ".$array[$i]; echo $sqlString; That ought to do it. --Niklas ----- Original Message ----- From: "dbarber" <dbarber@sailnet.com> To: <php-general@lists.php.net> Sent: Sunday, October 08, 2000 2:16 PM Subject: [PHP] loop during a mysql query > Hello, > > I want to run a mysql query where the object I'm searching on is pulled > from an array. The actual query would look something like this: > > "select email from position where description like 'linux' and [ next > value in array ] id ='7';" > > It would loop on the array values in the middle of the query. Can anyone > tell me how to actually get this code working? Here is what I have been > playing with. > > ------------------------------------------------------ > $selquery = "Select email from position where " . > > foreach($set_keywords as $value) > { > $line="description like '%$value%' and "; > $line > } > > . "id = '7' "; > -------------------------------------------------- > > > thanks, > > Dan

« previous php.general (#19085) next »