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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.