Jump to content

Advance Search Question in PHP....


jronyagz

Recommended Posts

Hello guys...

public function find_by_param($array) {
if ($array){

if ($array['item']['name'] = "") {
$condition_param .= " lower(firstname) LIKE '%".strtolower($array['item']['name'])."%'
                    OR lower(lastname) LIKE '%".strtolower($array['item']['name'])."%'";
} else {
$condition_param .= '';
}
if ($array['item']['keyword'] = "") {
$condition_param .= " AND lower(state) LIKE '%".strtolower($array['item']['keyword'])."%'";
} else {
$condition_param .= '';
}
if ($array['item']['city'] = "") {
$condition_param .= " AND lower(city) LIKE '%".strtolower($array['item']['city'])."%'";
} else {
$condition_param .= '';
}
if ($array['item']['province'] = "") {
  $condition_param .= " AND lower(province) LIKE '%".strtolower($array['item']['province'])."%' ";
} else  {
$condition_param .= '';
}
if (!$array['item']['country'] = "Any Country") {
$condition_param .= " And country = '".$array['item']['country']."' ";
} else {
$condition_param .= '';
}
if (!$array['item']['nationality'] = "Any Nationality") {
$condition_param .= " And nationality = '".$array['item']['nationality']."' ";
} else {
$condition_param .= '';
}
if (!$array['item']['height'] = "Any Height") {
$condition_param .= " And height = '".$array['item']['height']."' ";
} else {
$condition_param .= '';
}
if (!$array['item']['body_shape'] = "Any Body Shape") {
$condition_param .= " And body_shape = '".$array['item']['body_shape']."'";
} else {
$condition_param .= '';
}
if (!$array['item']['best_body_feature'] = "Any Body Feature") {
$condition_param  .= " And best_body_feature = '".$array['item']['best_body_feature']."' ";
} else {
$condition_param .= '';
}
if (!$array['item']['hair_color'] = "Any Hair Color") {
$condition_param  .= " And hair_color = '".$array['item']['hair_color']."' ";
} else {
$condition_param .= '';
}
if (!$array['item']['ethnicity'] = "Any Ethnicity") {
$condition_param  .= " And ethnicity = '".$array['item']['ethnicity']."' ";
} else {
$condition_param .= '';
}
if (!$array['item']['religion'] = "Any Religion") {
$condition_param  .= " And religion = '".$array['item']['religion']."' ";
} else {
$condition_param .= '';
}
if (!$array['item']['marital_status'] = "Any Marital Status") {
$condition_param  .= " And marital_status = '".$array['item']['marital_status']."' ";
} else {
$condition_param .= '';
}
if (!$array['item']['children'] = "Any Children") {
$condition_param  .= " And children = '".$array['item']['children']."' ";
} else {
$condition_param .= '';
}
if (!$array['item']['drinking'] = "Any Drinking") {
$condition_param  .= " And drinking = '".$array['item']['drinking']."' ";
} else {
$condition_param .= '';
}
if (!$array['item']['smoking'] = "Any Smoking") {
$condition_param  .= " And smoking = '".$array['item']['smoking']."' ";
} else {
$condition_param .= '';
}

$condition_param = $condition_param;
$query = "SELECT m.*
FROM members as m
$condition_param
ORDER BY firstname
";
$result = $this->find_by_sql($query);

return $result;

}
}


could anyone tell me whats wrong with this above code...any idea?
Link to comment
https://forums.phpfreaks.com/topic/29319-advance-search-question-in-php/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.