Re: formatting output: grouping results with identical fields - Mailing list pgsql-php

From scott.marlowe
Subject Re: formatting output: grouping results with identical fields
Date
Msg-id Pine.LNX.4.33.0305091601570.14159-100000@css120.ihs.com
Whole thread Raw
In response to formatting output: grouping results with identical fields  (Molly Gibson <molly_gibson2002@yahoo.com>)
Responses Re: formatting output: grouping results with identical fields
List pgsql-php
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.


pgsql-php by date:

Previous
From: Molly Gibson
Date:
Subject: formatting output: grouping results with identical fields
Next
From: Molly Gibson
Date:
Subject: Re: formatting output: grouping results with identical fields