"Sharif Islam" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> Is there any way, I can get only one output.But somehow I have to
> incorpate it with the other data in that column, which doesn't have
> multiple entry. Any hint? thanks in advance.



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
 <title>Sample code: Removal of duplicate categories by associative
array</title>
 <style type="text/css">
  body {
   font-family: Verdana, Arial, sans-serif;
  }
  .service {
   font-size: small;
   color: #000000;
   margin-top: 20px;
  }
  .machine {
   font-size: smaller;
   color: #743A44;
   margin-left: 20px;
   margin-top: 5px;
  }
 </style>
</head>
<body>

<?php
$conn = mysql_connect("host", "user", "pwd");
$result = mysql_db_query("db",
 "SELECT "
  ."services AS svc, "                    // set aliases for brevity
  ."machine_name AS mach "
 ."FROM table"
);                                                // ORDER BY is
unneccessary

// parse
$list = array();
while ($row = mysql_fetch_array($result))
  $list[$row[svc]][] = $row[mach];

// print
echo "\n<ul>";
foreach($list as $key => $machines) {
 echo "\n\t<li class='service'>$key<br>\n\t\t<span class='machine'>";

 $first = true;
 foreach($machines as $name) {
  echo ($first ? "" : " | ")."$name";        // could easily make this a
hyperlink
  $first = false;
 }

 echo "</span>\n\t</li>";
}
echo "\n</ul>";
?>

</body>
</html>




-- 
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]

Reply via email to