For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > October 2005 > Re: [PHP-DB] Detailed Report









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PHP-DB] Detailed Report
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
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com