[thelist] help w/design of SQL query

rudy r937 at interlog.com
Fri Nov 15 11:07:01 CST 2002


> $prev_cat = "";
> Loop through each result
>   if this row's category != $prev_cat
>       print "<h2>$category:</h2>";
>   end if
>   print "$item<br />";
>   $prev_cat = $category;
> End Loop

that's actually not too bad at all, thanks jason, i thought it would be
worse

somewhere along the line, i picked up the idea that in php you have to
store the result set in an array -- is that still necessary?

tom, compare to the coldfusion i posted the other day --

<cfoutput group=catname>
<p>#catname#
<cfoutput><br />#itemname#</cfoutput>
</p>
</cfoutput>

the category break logic is implicitly invoked by the group= parameter

sorry if it wasn't clear why i mentioned that

i was trying to illustrate the need for curr/prev logic

see the nested cfoutput?  that gets done for each row of the result set

the outer group= cfoutput is what gets done for each category

no matter which way curr/prev logic is implemented in your app, the sql is
still the same, and the result set the logic works on is the same

i think that's what jason intended by listing the sample data

mmmmmm...  fries...   lunch....


rudy





More information about the thelist mailing list