Re: formatting output: grouping results with identical fields

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Fri, 9 May 2003, Molly Gibson wrote:

> Hi list,
> Textile geek-grrl here--I recently created a postgres
> database to keep my fabric, pattern, & project
> inventory.  (Do I win a prize for 'weirdest thing for
> which someone has used postgres'?)

I'm certain there's someone out there doing something stranger than this.  

> This is great for my purposes, but I'd like to clean
> up the table a bit more and have the category only
> print once each time it occurs, and the manufacturer
> only print once in each category.  

What you can do is something like (this is pseudo code) before you start 
your while loop:

$current_category = <category from first row>

then in your while loop, check to see if it's changed:

if ($current_category != $new_category){
    print $new_category;
    $current_category = $new_category;
}

Get the idea? It works a charm for things like this.



[Index of Archives]     [Postgresql General]     [Postgresql Admin]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Yosemite Backpacking]     [Postgresql Jobs]

  Powered by Linux