Jump to content

Group data in rows


Stevenn

Recommended Posts

I have data

 

 

Name, Year, Month, Amount
==
A, 2012, nov, 14
A, 2012, dec, 48
A, 2012, jan, 8
B, 2011, feb, 17
B, 2011, aug, 10
(...)

 

 

How is it possible to group the names, so the output will be

 

Name, Feb2011, Aug2011, Jan2012, Nov2012, Dec2012
==
A, 0, 0, 8, 14, 48
B, 17, 10, 0, 0, 0

 

I have really no idea what function to look for.

Link to comment
Share on other sites

You need to use some logic in PHP. Where is the data coming from?

Basically you need to order them by the parent (In your case, A and B ) and then keep track of which one you're printing when you output.

I wrote an article about this on my site. It's using MySQL but the logic is the same no matter where your data comes from.

http://thewebmason.c...t-child-lists/

 

Just saw you posted this in MySQL so I'm going to assume it's a MySQL Database ;)

Edited by Jessica
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.