At 14:50 04.03.2003, Hunter, Jess spoke out and said: --------------------[snip]-------------------- >Here is the Base Line I am working with: > >$Query="SELECT * from $TableName WHERE lastname='$Array[lastname] AND >firstname='$Array[firstname]' "; > >What I ant to be able to do is a search on both the lastname and the >firstname so if someone just puts in the last name it will display all >people with the queried last name regardless of the first name. So for the >visual representation --------------------[snip]--------------------
$query = "select * from $tablename where " . (!empty($array['lastname']) ? "lastname = '{$array['lastname']}' " . (!empty($array['firstname']) ? 'and ' : null) : null) . (!empty($array['firstname']) ? "firstname = '{$array['firstname']}'" ; null); Note that you need to put curly braces around an array dereference if you have it in a quoted string. This doesn't work: $s = "Some $array[sample]"; But this works: $s = "Some {$array['sample']}"; -- >O Ernest E. Vogelsinger (\) ICQ #13394035 ^ http://www.vogelsinger.at/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php