Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > PHP Databases
PHP Databases Using PHP in conjunction with databases. PHP questions not specific to databases should be directed to one of the other PHP forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old March 25th, 2005, 04:51 AM
Registered User
Join Date: Mar 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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).

01|Tom |
04|Chris |


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.

Best regards,

Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL Query to Convert Columns into Rows Niaz Oracle 3 February 5th, 2010 07:08 AM
Query to change rows into columns and vice versa miamikk SQL Language 0 November 13th, 2007 06:41 PM
SQL Query to convert Columns into Rows....again phix SQL Server 2000 11 November 11th, 2007 09:59 AM
getting a query rows as columns raamts SQL Language 1 February 24th, 2005 04:06 AM
SQL Query to Convert Columns into Rows Niaz SQL Server 2000 2 April 20th, 2004 01:36 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.