RE: [PHP-DB] Detailed Report

From: Date: Thu, 27 Oct 2005 13:11:52 +0000
Subject: RE: [PHP-DB] Detailed Report
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-40548@lists.php.net to get a copy of this message
Let the code handle the separation of the products <?php $sql = "select * from table [where clause] order by cat"; //db connection here $result = mysql_query($sql); if (mysql_errno == 0) { if (mysql_num_rows($results)>0) { $old_cat = ""; while ($rows = mysql_fetch_array($result)) {
     //handle cat changes
     if ($old_cat != $rows['cat'])
     {
       echo "<tr><td>".$rows['cat']."<br />";
       $old_cat = $rows['cat'];
     }//end if
     //echo out the data
     echo $rows['name']."~".$rows['client_id']."~".$rows['city']."<br / >"
}//wend }else{ echo "no results found"; }//end if }//end if ?> bastien
From: Danny <metalito@gmail.com> To: php-db@lists.php.net Subject: [PHP-DB] Detailed Report Date: Thu, 27 Oct 2005 11:32:04 +0200 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.


« previous php.db (#40548) next »