Re: Loop through array, change headings [message #184433 is a reply to message #184432] |
Tue, 31 December 2013 21:22 |
Denis McMahon
Messages: 634 Registered: September 2010
Karma:
|
Senior Member |
|
|
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.
--
Denis McMahon, denismfmcmahon(at)gmail(dot)com
|
|
|