Hi,

Sorry about the stupid mistakes, should ofcourse have been:

$sqlstmt1 = "select category, name, code, city from table order by category";
$rs1 = mysql_query ($sqlstmt1);
$category='';

while ($row1 = mysql_fetch_object ($rs1) {
      if ($category != $row1->category) {
           $category = $row1->category;
           Print($category."<br>");
      } 
      Print($row1->name. '-' .$row1->code. '-' .$row1->city. "\n');    
}

Regards Henrik Hornemann


-----Oprindelig meddelelse-----
Fra: Henrik Hornemann [mailto:[EMAIL PROTECTED] 
Sendt: 27. oktober 2005 14:24
Til: php-db@lists.php.net
Emne: SV: [PHP-DB] Detailed Report

How about:

$sqlstmt1 = "select category, name, code, city from table order by category";
$categry='';
while ($row1 = mysql_fetch_object ($rs1) {
      if ($old_category != $row1->category) {
        $ category = $row1->category;
        Print($category."<br>");
      } 
      Print($row1->name. '-' .$row1->code. '-' .$row1->city. "\n');    
}


Regards Henrik Hornemann



-----Oprindelig meddelelse-----
Fra: Shahmat Dahlan [mailto:[EMAIL PROTECTED] 
Sendt: 27. oktober 2005 12:29
Til: Danny
Cc: php-db@lists.php.net
Emne: Re: [PHP-DB] Detailed Report

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

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to