Grouping output from a database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
john_crawford32
Forum Newbie
Posts: 9
Joined: Mon Mar 31, 2003 7:56 pm
Location: East Berlin, PA
Contact:

Grouping output from a database

Post by john_crawford32 »

I have a site
http://www.motorcyclesinretrospect.com/ ... ontent=cal

with a calendar of events.
I need to group the items by location, my field is State
What I want for example if there were 2 records from Maine it would look like

Maine

Date1 Event


Date2 Event

Maryland

Date1 Event.

I am not sure how to do this I don't think Group By in the SQL Statement is the answer here but I am not sure.
Thanks
John
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

you might use ORDER BY
then store the last value of State, if this value changes a new section begins (then store the new "old" value).
john_crawford32
Forum Newbie
Posts: 9
Joined: Mon Mar 31, 2003 7:56 pm
Location: East Berlin, PA
Contact:

Post by john_crawford32 »

OK, so I am overworked and my brain went on strike.
Thanks!
airo
Forum Commoner
Posts: 31
Joined: Thu Apr 24, 2003 4:07 pm

Post by airo »

john_crawford32 wrote:OK, so I am overworked and my brain went on strike.
Thanks!
Heh, that happens to the best of us...
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

perfectly normal condition ;)
Post Reply