Re: Still needing help with dynamic queries
| From: | Daniel Convissor | Date: | Fri, 01 Dec 2000 07:26:51 +0000 |
| Subject: | Re: Still needing help with dynamic queries | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-28171@lists.php.net to get a copy of this message | ||
Richard:
Richard Lynch wrote:
>
> <INPUT NAME=key[sex]><BR>
> <INPUT NAME=key[city]><BR>
> <INPUT NAME=key[state]><BR>
> <INPUT NAME=key[orientation]><BR>
> <INPUT NAME=key[status]><BR>
> <INPUT NAME=key[race]><BR>
> <INPUT NAME=key[option]><BR>
>
> <INPUT TYPE=RADIO NAME=strict VALUE=and> Strict
> <INPUT TYPE=RADIO> NAME=strict VALUE=or> Loose
>.....
> $query = "select * from personals where ";
> if ($strict=='and') $query .= " 1=1 "
> else $query .= " 1=0 ";
> while (list($field, $value) = each($key)){
> $query .= $strict . " $field = '$value' ";
> }
> }
You've got a great idea here. Seems you missed one important point. In a
personals database "Strict" v "Loose" are search parameters, not operators.
:)
--Dan
--
PHP scripts that make your job easier
http://www.analysisandsolutions.com/code/
SQL Solution | Layout Solution | Form Solution
T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
4015 7 Ave, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409