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
construct your query like
$query = select * from table where ;
lastname='$lastname' and
firstname='$firstname' and age='$age' and weight='$weight';
if (isset($lastname) and $lastname !=) then
$query.= lastname=$lastname ;
if (isset($firstname) and $firstname !=) then
$query.= and
$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(
3 matches
Mail list logo