Re: looping over field, keyword arrays to generate sql

From: Date: Fri, 09 May 2003 08:05:58 +0000
Subject: Re: looping over field, keyword arrays to generate sql
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-146980@lists.php.net to get a copy of this message
$fieldWordArray = Array("keyName"=>"keyValue","otherName"=>"otherValue"); foreach ($fieldWordArray as $key=>$value){ $sqlExtension .= "$key LIKE '%$value%' OR "; } $sqlExtension = substr($sqlExtension,0,strlen($sqlExtension)-4); "Joseph Blythe" <joseph@optcom.net.au> wrote in message news:001801c315c4$33b1a7c0$3500a8c0@ws53... > Hey everyone, > > Was wondering if anyone could point me to a algorithm to loop through two > arrays one being a list of keywords and the other a list of field names to > generate part of an sql statement like: > > $sql .= $field " LIKE '%" . $word . "%' OR " > > Have looked at many search scripts and classes but none really have this > part the way I would like it thought maybe someone may alreday have this or > could point me to a good example? > > Any help appreciated, > > Regards, > > Joseph Blythe >

« previous php.general (#146980) next »