[eluser]Jay Logan[/eluser]
It didn't work, but the following code almost works.
Model
Code:
function unique_counties($id_name)
{
$this->db->select();
$this->db->where('id_name', $id_name);
$get_data = $this->db->get('VSS_src_network');
$this->db->where_in('zip_code', explode(', ', $get_data->row()->addr_assoc));
$this->db->distinct();
$this->db->select('county_name');
$this->db->orderby('county_name');
$query = $this->db->get('JL_zip_codes');
$result = $query->result_array();
foreach($result as $county_info) {
$counties[] = $county_info['county_name'];
}
return $counties;
}
function unique_cities($id_name)
{
$this->db->select();
$this->db->where('id_name', $id_name);
$get_data = $this->db->get('VSS_src_network');
$this->db->where_in('zip_code', explode(', ', $get_data->row()->addr_assoc));
$this->db->distinct();
$this->db->select('city_name');
$this->db->orderby('city_name');
$query = $this->db->get('JL_zip_codes');
$result = $query->result_array();
foreach($result as $city_info) {
$cities[] = $city_info['city_name'];
}
return $cities;
}
Controller
Code:
function show($id_name)
{
$this->load->model('licensee_model');
$data['licensee_info'] = $this->licensee_model->licensee_info($id_name);
$this->load->library('table');
$table_options = array('table_open' => '<table width="100%">');
$this->table->set_template($table_options);
$counties_list = $this->table->make_columns($this->licensee_model->unique_counties($id_name), 5);
$data['counties_table'] = $this->table->generate($counties_list);
$cities_list = $this->table->make_columns($this->licensee_model->unique_cities($id_name), 5);
$data['cities_table'] = $this->table->generate($cities_list);
$this->load->view('profile', $data);
}
The problem now is that the counties also show in the city list.