|
Posted by "Richard Lynch" on 10/29/05 23:47
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
[Back to original message]
|