--- Mladen Milankovic <[EMAIL PROTECTED]> wrote:

> >
> >  $query =
> >     "SELECT *
> >      FROM $table ";
> >      if($source != "All") $query .= "and source = '".$source."'";
> >      if($hardware != "Both") $query .= "and hardware = '".$hardware."'";
> >      if($plant != "All") $query .= "and plant = '".$plant."'";
> >      if($area != "All") $query .= "and area = '".$area."'";
> -------------------------
> 
> Hi.
> 
> The problem here is that theres no WHERE nowhere in the sentence, and
> there's nowhere space in the "$query .=" lines
> If all criterias are true you would get something like this:
> SELECT * FROM $table and source = 'something'and hardware =
> 'something'and plant = 'something'and area = 'something'
> 
> The code that would work looks like this:
> 
> $query =
>   "SELECT *
>    FROM $table ";
> if($source != "All" || $hardware != "Both" || $plant != "All" || $area
> != "All") $query .= "WHERE ";

Or you could be clever and use:

$query = "SELECT * FROM $table WHERE 1 ";

and then build on the query with your conditional statements.

James

Reply via email to