On Fri, Aug 01, 2003 at 03:00:23AM -0500, John T. Beresford wrote:
> Hi All,
> 
> I'm having a hard time wrapping my head around this. I have a query 
> that returns the following (Sorted by col2):
> 
> col1  col2
> -------------
> house1        Com1
> house2        Com1
> house3        Com2
> house4        Com2
> house5        Com3
> house6        Com3
> 
> 
> I would like to display it as shown below:
> 
> Com 1
> house1 - Com1
> house2 - Com1
> 
> Com 2
> house3 - Com2
> house4 - Com2
> 
> Com 3
> house5 - Com3
> house6 - Com3
> 
> 
> I'm having a problem with the header for each 'com'
> 
> Thanks for any pointers,
> John

i think this is a common task. you can try something like:

$last = null;
while ( list($col1, $col2) = fetch_next_row() ) {
        if ($last != $col2) {
                echo "\n$col2\n";
                $last = $col2;
        }
        echo "$col1 - $col2\n";
}



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to