[thelist] CFQuery "Group" in PHP

Jeff Howden jeff at jeffhowden.com
Thu Aug 12 15:15:17 CDT 2004


Russ,

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><
> From: russ at unrealisticexpectations.com
> 
> I'm a bit of a mediocre CF developer some days, and
> somedays I'm a novice hack in PHP, which is what I'm
> currently working in.  I'm trying to find an equivalent
> to <CFQUERY group="ownerTitle"> in PHP so that I can do
> this:
> 
> <LINK OWNER>
> Link 1
> Link 2
> 
> <LINK OWNER>
> Link 1
> Link 2
><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

First, there is no equivalent to <cfquery group="ownerTitle">, not even in
ColdFusion.  I think what you're asking about is <cfoutput query="getlinks"
group="ownerTitle">.  Even with that correction, there is no equivalent in
any language I've ever seen.

Second, I would never torture myself with PHP, but the long-hand method of
doing a grouped query output is simple enough logic.  Here it is in
pseudo-code:

last_owner = '';
for(currentrow in myQuery.recordcount;)
{
  if(last_owner != linkowner)
  {
    write('<h2>' + linkowner + '</h2>');
    last_owner = linkowner;
  }
  write(link);
}

Good luck,

Jeff
------------------------------------------------------
Jeff Howden - Web Application Specialist
Resume - http://jeffhowden.com/about/resume/
Code Library - http://evolt.jeffhowden.com/jeff/code/




More information about the thelist mailing list