Re: creating a SELECT AND query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 18/04/06, Ross <ross@xxxxxxxxxxxxx> wrote:
>
> $query1= "select * from $table_name WHERE sname LIKE '$search_string%' ";
>
> if ($area="a")  {
> $query1 .=" AND area='a'";
>  }
>  else {
>   $query1 .="AND area='$area'";
>   }

Firstly, you're assigning "a" to area rather than testing whether
$area is "a". You need a "==" operator, not a "=".

Secondly, even if you were testing $area properly, you're doing the
same thing in both halves of the if-statement. Which isn't very
useful.

Really, you only need the "AND area='?'" part if $area is not equal to "a":

if ($area != "a") {
   $query1 .= " AND area='$area'";
}

  -robin

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux