Posted by Peter Butler on 11/09/50 11:22
Geoff Berrow <blthecat@ckdog.co.uk> wrote in message
> Lets take a simple case. Say I sell shoes and I have three fields,
> size, colour and type.
>
> After sanitizing the input from the form (using
> mysql_real_escape_string() ) we could end up with three variables $size,
> $colour and $type
YES... you will always have THREE different variables BUT you will also have
EIGHT different possible combinations of those three variables:
if none are set *// show me all shoes
elseif only A is set *// show me a specified size in any colour and any
type
elseif only B is set *// show me a specified colour in any size and any
type
elseif only C is set *// show me a specified type in any colour and any
size
elseif only A&B is set *// show me specified size & colour but in ANY TYPE
elseif only A&C is set *// show me specified size & type but in ANY COLOUR
elseif only B&C is set *// show me specified colour & type but in ANY SIZE
elseif A&B&C is set *// show me ONLY shoes of single size in ONE colour and
of ONE TYPE
this is quick and easy as long as U only have few variabes... (3 in above
case)
now try do the same with 15 variables and I think U get my point.
My problem is not in structuring the actual sql query... my problem is to
create a single dynamic if( ) which will
depend on which variables have been set.
[Back to original message]
|