Re: Loop through array, change headings [message #184437 is a reply to message #184433] |
Tue, 31 December 2013 23:40 |
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
|
|
|