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
Re: Loop through array, change headings [message #184437 is a reply to message #184433] Tue, 31 December 2013 23:40 Go to previous messageGo to previous message
Adrienne Boswell is currently offline  Adrienne Boswell
Messages: 25
Registered: October 2010
Karma:
Junior Member
Denis McMahon <denismfmcmahon(at)gmail(dot)com> wrote

> On Tue, 31 Dec 2013 21:08:42 +0000, Adrienne Boswell wrote:
>
>> 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.
>
> Something like the following (untested, may not use the right call
names
> etc) php:
>
> $class = "";
> while ( $row = result->get_row_assoc() !== false ) {
> if ( $class != $row["classification"] ) {
> $class = $row["classification"];
> output "-" . $class . "\n";
> }
> output " " . $row["category"];
> }
>
> Loop through the result set, every time the class of the record doesn't
> match the existing class, output the class header.
>

Dennis, thank you so much, that worked beautifully!

--
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 Sep 19 01:56:39 GMT 2024

Total time taken to generate the page: 0.07364 seconds