$where_conditions = array();
if( !empty( $lastname ) ){
$where_conditions[] = "lastname like '%${lastname}%'";
}
if( !empty( $firstname ) ){
$where_conditions[] = "firstname like '%${firstname}%'";
}
if( !empty( $age ) ){
$where_conditions[] = "age = ${age}";
}
if( !empty(
;t
add the "AND ".
Hope that helps.
- Original Message -
From: "Phil Schwarzmann" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Tuesday, January 15, 2002 3:53 PM
Subject: [PHP] Another question - not ex
how 'bout something like
$query = 'select * from table_name where ';
$and = '';
if ($lastname != '') {
$query .= "lastname = $lastname";
$and = ' and ';
}
if ($firstname != '') {
$query .= $comma."firstname = $firstname;
$and = ' and ';
}
and so on
on 1/15/02 1:53 PM, Phil Schwarzmann at [E
Yo, thanks for all your help. But it isn't exactly what im looking for.
Let's say you had a database with the following four columns...
-LastName
-FirstName
-Age
-Weight
...and you wanted a page that would allow a user to search for one or
more of these fields within the database.
It would be
4 matches
Mail list logo