Re: Multiple Entry

From: Date: Wed, 01 Aug 2001 18:06:45 +0000
Subject: Re: Multiple Entry
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-10964@lists.php.net to get a copy of this message
"Sharif Islam" <mislam@students.uiuc.edu> wrote in message news:Pine.GSO.4.31.0108011125570.27460-100000@ux5.cso.uiuc.edu... > 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>

« previous php.db (#10964) next »