seefor Posted February 23, 2009 Share Posted February 23, 2009 Sorry for the silly question, I'm new to PHP ;D Below is my report.php file: <?php require_once('../Connections/Sencore.php'); ?> <?php mysql_select_db($database_Sencore, $Sencore); $query_subVer = "SELECT * FROM `1067`"; $subVer = mysql_query($query_subVer, $Sencore) or die(mysql_error()); $row_subVer = mysql_fetch_assoc($subVer); $totalRows_subVer = mysql_num_rows($subVer); ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <link href="../assets/css/style.css" rel="stylesheet" type="text/css" /> </head> <body> <table border="1"> <tr> <td>IPAddress</td> <td>Notes</td> <td>alias</td> <td>unitversion</td> <td>decoderVersion</td> <td>tssid</td> <td>stationname</td> </tr> <?php do { ?> <tr> <td><?php echo $row_subVer['IPAddress']; ?></td> <td><?php echo $row_subVer['Notes']; ?></td> <td><?php echo $row_subVer['alias']; ?></td> <td><?php echo $row_subVer['unitversion']; ?></td> <td><?php echo $row_subVer['decoderVersion']; ?></td> <td><?php echo $row_subVer['tssid']; ?></td> <td><?php echo $row_subVer['stationname']; ?></td> </tr> <?php } while ($row_subVer = mysql_fetch_assoc($subVer)); ?> </table> </body> </html> <?php mysql_free_result($subVer); ?> The output looks like this: 10.67.10.56 RX BU AUSTIN 6.3.0 6.3.0 10.67.10.35 RX 04 AUSTIN 6.3.0 6.3.0 10.67.10.34 RX 03 AUSTIN 6.3.0 6.3.0 10.67.10.33 RX 02 AUSTIN 6.3.0 6.3.0 10.67.10.32 RX 01 AUSTIN 6.3.0 6.3.0 10.67.12.56 RX BU DALLAS 6.3.0 6.3.0 10.67.12.35 RX 04 DALLAS 6.3.0 6.3.0 10.67.12.34 RX 03 DALLAS 6.3.0 6.3.0 10.67.12.33 RX 02 DALLAS 6.3.0 6.3.0 10.67.12.32 RX 01 DALLAS 6.3.0 6.3.0 What I'm trying to accomplish is that the output looks like this: AUSTIN 10.67.10.56 RX BU 6.3.0 6.3.0 10.67.10.35 RX 04 6.3.0 6.3.0 10.67.10.34 RX 03 6.3.0 6.3.0 10.67.10.33 RX 02 6.3.0 6.3.0 10.67.10.32 RX 01 6.3.0 6.3.0 DALLAS 10.67.12.56 RX BU 6.3.0 6.3.0 10.67.12.35 RX 04 6.3.0 6.3.0 10.67.12.34 RX 03 6.3.0 6.3.0 10.67.12.33 RX 02 6.3.0 6.3.0 10.67.12.32 RX 01 6.3.0 6.3.0 I have no clue what to google to find something similar to this... ??? ??? ??? Any suggestions would greatly help, thanks in advance. SeeFor Quote Link to comment https://forums.phpfreaks.com/topic/146555-solved-php-grouping-output/ Share on other sites More sharing options...
sasa Posted February 23, 2009 Share Posted February 23, 2009 try <?php require_once('../Connections/Sencore.php'); ?> <?php mysql_select_db($database_Sencore, $Sencore); $query_subVer = "SELECT * FROM `1067` ORDER BY decoderVersion"; $subVer = mysql_query($query_subVer, $Sencore) or die(mysql_error()); $row_subVer = mysql_fetch_assoc($subVer); $totalRows_subVer = mysql_num_rows($subVer); ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <link href="../assets/css/style.css" rel="stylesheet" type="text/css" /> </head> <body> <table border="1"> <tr> <td>IPAddress</td> <td>Notes</td> <td>alias</td> <td>unitversion</td> <td>tssid</td> <td>stationname</td> </tr> <?php $curr_dec=''; do { if ($row_subVer['decoderVersion'] != $curr_dec){ echo "<tr><td colspan=\"6\">decoderVersion: $row_subVer[decoderVersion]</td></tr>"; $curr_dec = $row_subVer['decoderVersion']; } ?> <tr> <td><?php echo $row_subVer['IPAddress']; ?></td> <td><?php echo $row_subVer['Notes']; ?></td> <td><?php echo $row_subVer['alias']; ?></td> <td><?php echo $row_subVer['unitversion']; ?></td> <td><?php echo $row_subVer['tssid']; ?></td> <td><?php echo $row_subVer['stationname']; ?></td> </tr> <?php } while ($row_subVer = mysql_fetch_assoc($subVer)); ?> </table> </body> </html> <?php mysql_free_result($subVer); ?> Quote Link to comment https://forums.phpfreaks.com/topic/146555-solved-php-grouping-output/#findComment-769411 Share on other sites More sharing options...
seefor Posted February 23, 2009 Author Share Posted February 23, 2009 sasa, Thanks a million, that's excatly what I'm looking for. SeeFor Quote Link to comment https://forums.phpfreaks.com/topic/146555-solved-php-grouping-output/#findComment-769423 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.