Hi there,
I have a query where I am trying to retrieve some data and place in an array within an array. So I have this query
SELECT *,
GROUP_CONCAT(notes.notes_ids Separator "~") as allids
GROUP_CONCAT(notes.notes Separator "~") as allnotes
FROM customer as c
LEFT JOIN notes on notes.customer_id_fk = c.customer_id
GROUP BY c.customer_id
then the while part
while($row = mysql_fetch_assoc($result)){
$customer = $row;
$customer[$row[notes]]['new_ids'] = explode('~', $customer[$row]['allids']);
$customer[$row[notes]]['new_notes'] = explode('~', $customer[$row]['allnotes']);
}
There may be some confusing bit there as I haven't tested that, just writing off hand.
Anyway what I get from customer when print_r the array is something like this:
[0]=>[name] =>customername
[lastname]=>customerlastname
etc...
and then i end up with
[new_ids] =>array( [0]=>1 [1]=>2)
[new_notes =>array([0]=>a note [2]=>another note)
What I would like to end up with in the main array is
[notes] =>array([0][new_ids] = 1 [new_notes] = a note
[1][new_ids] = 2 [new_notes] = another note)
so that the notes array is nice an easy to loop through.
What am I doing wrong? Is there a way to do what I am trying to get at?
Thanks!