[PHP-DB] Group By problem

2001-08-13 Thread Sharif Islam

I am trying to caregorize to group at the same time, but its not working.
Any hints?
Here's my code:
$temp=Dummy;
while ($row = mysql_fetch_array($result))
{
 if($temp !=$row[group_name]){
 $temp=$row[group_name] ;
 echo bGroup:$tempbr/b;

}

$temp1=blah;
if($temp1 !=$row[service_cat]){
$temp1=$row[service_cat];
echo Services:$temp1br;
}
$machine_name=$row[machine_name];
echo a
href=view_server.php?machine_name=$machine_name$machine_name/abr;
}

This is displaying :
Group:Group_Name
Services:Email
Machine_Name
Services:Email
Machine_name2
Services: Backup
Machine_name
Group:Group_name2

I dont want to print services multiple times. Just like the group name
catagorize it.

Thanks




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] Group By problem

2001-08-13 Thread Hugh Bothwell


- Original Message - 
From: Sharif Islam [EMAIL PROTECTED]
To: Hugh Bothwell [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
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: #44;
}
.service {
font-weight: bold;
color: #77;
}
.machine {
font-size: 80%;
color: #77;
}
/style

?php

function PrintNewGroup($grp) {
echo br\nspan class='group'$grp/span;
}

function PrintNewService($svc) {
echo br\n\tspan class='service'$nbsp;$svc/spanbr;
}

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?

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]