Formatting sql query rows as columns with stack
Here's a non-trivial problem I faced recently.
I have two tables: Users and Transports. Users is obvious, Transport stores transport data (date, place, case_no, user).
What I would like to do is to make an HTML table with Users as columns and transports as rows, BUT I would like to show one transport per user in each row so that it make a sort of an inverted stack. The output should look like this:
| Tom | Martin | Maggie | Chris |
|2004-10-02, France, 04/05|2004-09-02, Italy, 03/05 |2004-10-14, Germany, 08/05| |
| |2004-10-06, Italy, 07/05 |2004-10-14, Belgium, 09/05| |
| |2004-10-15, Austria, 10/05| | |
My question is: how to get such a result using PHP instructions. I suppose it would require some multidimensional array manipulations. Does anyone have any idea how to do it?
I'll be very grateful for any help.