Jump to content

Outputting a table


grissom

Recommended Posts

Hi, I am looking to output a MYSQL table in a certain way. Here's an example, imagine I have a sales database like this

 

Staff          Day      Place      Sales

====        ===      ====      =====

Alice          MON    Town        5

Alice          MON    City          6

Alice          TUE      Town        7

Bob          TUE      Town        3

Bob          TUE      City          2

 

And I'd like to turn it into something like this :

 

Total Sales by Day

 

                MON        TUE   

Alice          11            7       

Bob            0            5

 

For sure I can do it in PHP using a few "loops" but is there a way to do it in a single MYSQL statement ?

Link to comment
https://forums.phpfreaks.com/topic/229485-outputting-a-table/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.