Re: Detailed Report
| From: | Richard Lynch | Date: | Sat, 29 Oct 2005 20:47:06 +0000 |
| Subject: | Re: Detailed Report | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-224831@lists.php.net to get a copy of this message | ||
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 " $category<br />\n";
$last_category = $category;
}
echo "$name - $code - $city<br />\n";
}
--
Like Music?
http://l-i-e.com/artists.htm