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 #184433 is a reply to message #184432] Tue, 31 December 2013 21:22 Go to previous messageGo to previous message
Denis McMahon is currently offline  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
[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: Sat Nov 30 16:12:51 GMT 2024

Total time taken to generate the page: 0.06694 seconds