[eluser]mdcode[/eluser]
To start off with the situation, I have a dropdown select menu, which when the selection changes, it grabs a list of names for whoever is in that group (the dropdown lists the group names). This is all very well and I have this working.
However the problem comes when someone belongs to multiple groups.
In the 'person' table I have a comma delimited numerical list of group numbers (pertaining to the id in the groups table, such as 1,2,4,5,6,12.
When I use the select 'Group' dropdown to select on of these listed groups, the only names that appear on the list are those where they are only a member of one group, so in other words....
I have 3 people, Jack, Mary and Clive.
Jack is a member of group 1.
Mary is in group 2.
Clive is a member of both groups, 1 and 2 (using the method above).
I select group 1 from the list, but only Jack's name appears when Clive should appear as well.
Here's my code:
CONTROLLER:
Code:
function div_names_list()
{
/* set the POST variable */
$division = $this->input->post('division', TRUE);
/* grab the division details */
$names = $this->complaint->get_division($division);
/* check the existence of a names list and print */
if ($names !== FALSE)
{
foreach ($names as $key=>$value)
echo $value['first_name'] . ' ' . $value['last_name'] . ', ';
}
}
MODEL:
Code:
function get_division($division = '')
{
$this->db->select('first_name, last_name');
$this->db->from('users');
$this->db->where('division',$division);
$query = $this->db->get();
return ($query->num_rows) ? $query->result_array() : FALSE;
}
I'd appreciate anyone shedding some light on this please.