Re: Detailed Report

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

 



On Thu, October 27, 2005 4:26 am, Danny wrote:
>  I´ve got a connection, to a MySQL db, and get the following
> ResultSet(Category | Name | Code | City)
>  Customers | John | A36 | New York
> Customers | Jason | B45 | Los Angeles
> Customers | Max | A36 | Paris
> Providers | John | A36 | London
> Providers | Mark | B67 | Madrid

You must make sure that your query has:

ORDER BY Category

in it, and any other ordering (Name, Code, City) comes *AFTER* Category.

Otherwise, your Customers and Providers get all jumbled up, and you
can't easily separate them.

> And I need the report in the following format:

$last_category = '';
while (list($category, $name, $code, $city) = mysql_fetch_row($result)){
  //Only print out Category when we find a new one:
  if ($last_category != $category){
    echo " &nbsp; $category<br />\n";
    $last_category = $category;
  }
  echo "$name - $code - $city<br />\n";
}

-- 
Like Music?
http://l-i-e.com/artists.htm

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux