For Programmers: Free Programming Magazines  


Home > Archive > PHP Language > August 2007 > Displaying Grouped Data









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Displaying Grouped Data
Simon Harris

2007-08-05, 9:59 pm

Hi,

Can anyone give me any hints as to how I can display grouped data, e.g. I
have a query that returns 20 rows, which are grouped into different areas,
i.e. One of the coumns only has 4 distinct values, where the rest are
distinct per row.

What I want to do, is display a list that prints the first of the 4
disntinct values, then the rest of the records in that group, then the 2nd
distinct value, then the records in that group...and so on. But...I only
want to display the group names once - Not for each row.

I do hope that is clear...Not the easiest of scenarios to explain!

Thank you!!

Simon.

--
--
* Please reply to group for the benefit of all
* Found the answer to your own question? Post it!
* Get a useful reply to one of your posts?...post an answer to another one
* Search first, post later : http://www.google.co.uk/groups
* Want my email address? Ask me in a post...Cos2MuchSpamMakesUFat!


Usenet

2007-08-06, 6:58 pm

In article <ovsti.14471$6z6.7124@newsfe1-gui.ntli.net>, Simon Harris wrote:
> Can anyone give me any hints as to how I can display grouped data,


I'd write it in the loop.
You're (presumably) using a "foreach" or somesuch to loop through the rows
returned.
You just need to keep a note of the last distinct value displayed. If "this"
row has the same value in that column then don't display it.

It perhaps appears a bit tedious, but you're display criterion for this
column is "is it the same value as last time", so that's what you've got to
do, "remember" what happened last time.

Regards
Mark

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com