Re: Group By problem

From: Date: Mon, 13 Aug 2001 16:13:26 +0000
Subject: Re: Group By problem
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-11300@lists.php.net to get a copy of this message
----- Original Message ----- From: "Sharif Islam" <mislam@students.uiuc.edu> To: "Hugh Bothwell" <hugh_bothwell@hotmail.com> Cc: <php-db@lists.php.net> Sent: Monday, August 13, 2001 11:50 AM Subject: Re: [PHP-DB] Re: Group By problem > But its displaying the same as my code: The SQL was just for reference, to make sure we were both working on the same basis... I don't think you looked at the PHP code I gave, as it should produce exactly what you are asking for. > Group:Desktop > Service:BACKUP > AITSBKUP > Service:E-Mail > AITSMAIL > JEEVES > Group:Unix > Service:Database > APOLLO > Service:FIREWALL > Console try defining <style> body { font-family: Verdana, Arial, sans-serif; } .group { font-weight: bold; font-size: 120%; color: #000044; } .service { font-weight: bold; color: #000077; } .machine { font-size: 80%; color: #770000; } </style> <?php function PrintNewGroup($grp) { echo "<br>\n<span class='group'>$grp</span>"; } function PrintNewService($svc) { echo "<br>\n\t<span class='service'>$nbsp;$svc</span><br>"; } function PrintMach($mach, $first) { if ($first) echo "&nbsp;&nbsp;" else echo "&nbsp;|&nbsp;"; echo "<span class='machine'>$mach</span>"; } ?> > > $grp=""; > > $svc=""; > > $firstmach = true; > > while ($row=mysql_fetch_array($result)) { > > if ($grp != $row["grp"]) { > > $grp = $row["grp"]; > > PrintNewGroup($grp); > > $svc = ""; // force new-svc when switching groups > > } > > > > if($svc != $row["svc"]) { > > $svc = $row["svc"]; > > PrintNewService($svc); > > $firstmach = true; > > } > > > > PrintMach($row["mach"], $firstmach); > > $firstmach = false; > > } How's that?

« previous php.db (#11300) next »