• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Array in an array, I think

#1
[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.


Messages In This Thread
Array in an array, I think - by El Forum - 08-10-2009, 08:46 PM
Array in an array, I think - by El Forum - 08-10-2009, 09:21 PM
Array in an array, I think - by El Forum - 08-10-2009, 09:35 PM
Array in an array, I think - by El Forum - 08-10-2009, 09:46 PM
Array in an array, I think - by El Forum - 08-11-2009, 12:31 AM
Array in an array, I think - by El Forum - 08-11-2009, 12:50 AM
Array in an array, I think - by El Forum - 08-11-2009, 01:16 AM
Array in an array, I think - by El Forum - 08-11-2009, 05:28 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.