Reputation: 784
I retrieve data from database using this query:
SELECT * FROM tickets_departement_groups WHERE group_id = '{$user_group}'
$user_group
is already defined, and I fetch the data using mysql_fetch_array
, like this:
foreach ($query->result_array() as $row) { return $row['departement_id']; }
All this is under a function called get_departement_id()
, So when I do echo get_departement_id();
it prints last departement ID, but I have many of them. What I want to do is to output all the department IDs for a given query.
Upvotes: 0
Views: 86
Reputation: 599
create and array and return the array?
$id_list = array();
foreach($query->result_array() as $row){
$id_list[] = $row['departement_id'];
}
return $id_list;
Upvotes: 3