Re: Re: Help: Database Search
| From: | Stuart Felenstein | Date: | Fri, 12 Nov 2004 12:42:00 +0000 |
| Subject: | Re: Re: Help: Database Search | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-201839@lists.php.net to get a copy of this message | ||
--- Sebastian Mendel <lists@sebastianmendel.de> 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