Reply to Re: [PHP] Detailed Report

Your name:

Reply:


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 " &nbsp; $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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация