| Shahmat Dahlan 2005-10-27, 7:55 am |
| Not sure whether this would be such a good idea. Does anybody else have
a better one than this?
#main loop, gather distinct / unique category names
$sqlstmt = "select distinct(category) as category from table";
$rs = mysql_query ($sqlstmt);
while ($row = mysql_fetch_object ($rs)) {
print $row->category . "\n"; # output Customers / Providers
$sqlstmt1 = "select name, code, city from table";
$rs1 = mysql_query ($sqlstmt);
# inner loop, display those which category is from the main loop
while ($row1 = mysql_fetch_object ($rs1) {
print $row1->name . '-' . $row1->code . '-' . $row1->city .
"\n'; # output John - A36 - City
}
}
Danny wrote:
>Hi All,
> 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
>And I need the report in the following format:
> Customers
>John - A36 - New York
>Jason - B45 - Los Angeles
>Max - A36 - Paris
> Providers
>John - A36 - London
>Mark - B67 - Madrid
> Any one can help? I´m a bit stalled
> thx
>regards.
>
>
>
--
Best Regards,
Shahmat Dahlan
Research and Development
SAINS
Mobile: (60)16 882 6130
Office: (60)82 426 733 ext 5512
|