RE: [PHP] Populating HTML List boxes From DB
| From: | Peter Houchin | Date: | Tue, 17 Apr 2001 01:48:19 +0000 |
| Subject: | RE: [PHP] Populating HTML List boxes From DB | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-48858@lists.php.net to get a copy of this message | ||
Thanks Jason... I've used SELECT DISTINCT ... now i doubt this has anything to do with SELECT
DISTINCT as such but for some reason its only displaying the last vaule entered
<select name="device">
<?php
$query ="SELECT DISTINCT device FROM 3backup ORDER BY device";
$rs =mysql_query($query);
$device = mysql_result($rs, 'device');
while($row = mysql_fetch_object($rs)){
echo '<option value="';
echo $device;
echo '">';
echo $device;
echo '</option>\n';
}
?>
</select>
Any suggestions?
Peter
-----Original Message-----
From: Jason Murray [mailto:Jason.Murray@melbourneit.com.au]
Sent: Tuesday, April 17, 2001 11:12 AM
To: 'Peter Houchin'; Php-General@Lists. Php. Net
Subject: RE: [PHP] Populating HTML List boxes From DB
> say in my db i have multiple values that are the same as well
> as different values... how can i restrict it to showing each
> value just once?
Sounds like you want a "SELECT DISTINCT".
You might want to have a look at www.sqlcourse.com.
Jason