function SearchMembers()
{
// grab user input
//$my_gender = $this->security->xss_clean($this->input->post('my_gender'));
$this->security->xss_clean($this->input->post('looking_for_gender'));
$age_from = $this->security->xss_clean($this->input->post('age_from'));
$age_to = $this->security->xss_clean($this->input->post('age_to'));
$member_postcode = $this->security->xss_clean($this->input->post('postcode'));
$member_distance = $this->security->xss_clean($this->input->post('distance'));
// Prep the query
$this->db->where('Gender', $looking_for_gender);
$this->db->where('Age >=', $age_from);
$this->db->where('Age <=', $age_to);
$miles = $this->search_form_model->distCalc('postcode',$member_postcode);
$this->db->where($miles < $member_distance);
// Run the query
$query = $this->db->get('member');
// Let's check if there are any results
if ($query->num_rows() > 0)
{
foreach ($query->result() as $row)
{
return $query->result();
}
// If the previous process did not validate
// then return false.
return false;
}
}
Hope someone can help. I'm performing a distance check between two postcodes in miles, and add all the ones that are less than distance to the result.
Previously all I have done is iterated through all postcodes that match gender and age then done a miles less than distance check and but the results in a json array, now a want to perform it within the mysql query if possible ideally using codeigniter framework. many thanks