FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Loop through array, change headings
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Loop through array, change headings [message #184432] Tue, 31 December 2013 21:08 Go to previous message
Adrienne Boswell is currently offline  Adrienne Boswell
Messages: 25
Registered: October 2010
Karma:
Junior Member
I'm sure this has been asked and answered, but I am either too stupid to
figure out the right way to ask Google, or I'm lazy, or it really hasn't
been asked. Sorry in advance, and if it has been answered, please refer
me as needed.

Here's my situation:
I have a table that has three classifications:
id Classification
1 Stores
2 Restaurants
3 Services

I have another table that has categories in each classification, eg.
id Category Classification_id
1 Market 1
2 Pet Shop 1
3 Pizza 2
4 Sandwich 2
5 Notary 3
6 Repair 3

My query is
SELECT c.id, category, classification, cl.id AS classid FROM category
c JOIN classification cl ON c.classification_id = cl.id ORDER BY classid,
category

What I want to do is:
-Stores
Market
Pet Shop
-Restaurants
Pizza
Sandwich
-Services
Notary
Repair


So, as I'm looping through my recordset, if the classid has changed, I
want to change the header. I don't want to make one query to get the
headings, and then do another query for each classid. I KNOW there has
got to be a better way.

I'm trying to get this all done so I can have a Happy New Year, and
wishing you and yours a Happy New Year as well.

--
Adrienne Boswell
Arbpen Web Site Design Services - http://www.cavalcade-of-coding.info/
The Good Plate - Fresh Gourmet Recipes - http://the-good-plate.com/
Please respond to the group so others can share
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: thank you, richard@noreply
Next Topic: PHP sql entry is a godaweful mess
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 21 21:27:32 GMT 2024

Total time taken to generate the page: 0.04448 seconds