Without actually giving all the details of my query: Is there a way of joing the results of two separate queries on different tables?
for example if i had a table
I strongly suggest posting your SQL so a proper solution can be achieved. That is to say you should do this with MySQL instead of PHP.
However, you will need to loop over your first set of records and build an array. Then loop over the second, appending it to the first set where the id matches.