I think you're implode example is pretty close. <?php $Ind = ""; $Ind = $_POST['Ind']; if(is_array($Ind) { if (count($Ind) > 1) { $IndStr = implode("','", $Ind); $where[] = "vendorjobs.Industry IN($IndStr)"; }else{ $where[] = "vendorjobs.Industry = {$Ind[0]}"; }else{ // Is there an error if not an array? } $sql = 'SELECT ... FROM vendorjobs WHERE ' . implode( ' AND ', $where ); ?> Not sure if you need the {} above, I think you do as it's an array reference in a string. This should result in: WHERE vendorjobs.Industry IN (2,3,5) OR WHERE vendorjobs.Industry = 2 HTH Graham > -----Original Message----- > From: Stuart Felenstein [mailto:stuart4m@xxxxxxxxx] > Sent: 12 November 2004 12:42 > To: Sebastian Mendel; php-general@xxxxxxxxxxxxx > Subject: Re: Re: Help: Database Search > > > > --- Sebastian Mendel <lists@xxxxxxxxxxxxxxxxxx> wrote: > > > > $where = array(); > > > > if ( isset($_POST['Ind']) ) { > > $where[] = 'vendorjobs.Industry = ' . (int) > > $_POST['Ind']; > > } > > if ( isset($_POST['Days']) ) { > > $where[] = 'Date_Sub(Curdate(), interval ' . > > (int) $_POST['Days'] . > > ' day) <= PostStart'; > > } > > > > $sql = ' > > SELECT ... > > FROM vendorjobs > > WHERE ' . implode( ' AND ', $where ); > > > > Sebastian, I meant to thank you for this code the > other day. > What I'm trying to figure out is some of my elements > are arrays themselves. So for example I have this : > > $Ind = ""; > $Ind = $HTTP_POST_VARS['Ind']; > if (count($Ind) > 0 AND is_array($Ind)) { > $Ind = "'".implode("','", $Ind)."'"; > } > > So how would this code , or array get into what you > stated as: > > > $where = array(); > > > > if ( isset($_POST['Ind']) ) { > > $where[] = 'vendorjobs.Industry = ' . (int) > > $_POST['Ind']; > > } > > I guess that is putting an array into an array ? > Not quite sure how the loop would go. > > Thank you, > Stuart > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php