CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   PHP (http://www.codingforums.com/forumdisplay.php?f=6)
-   -   Populate HTML Drop Down Box From MySQL Data (http://www.codingforums.com/showthread.php?t=280271)

penny94 11-01-2012 01:23 AM

Populate HTML Drop Down Box From MySQL Data
 
Edit: Solved!

PHP Code:

$query "SELECT DISTINCT category FROM browse"

--------------------------


I have a piece of code that gets data from my MySQL Table and puts it into a drop down box. It works great. However I don't want it to duplicate rows.

For example some things in the table have the same category and at the moment it displays the category multiple times in the drop down box.

How can I avoid this?


PHP Code:


Select a category: <select id="dropdown" name="cat">
  <?php
include 'config.inc';
$query "SELECT * FROM browse";
$result mysql_query($query) or die (mysql_error());
while(
$row mysql_fetch_array($result)) {



?><option><?php echo $row['category']; ?></option>
<?php
}
?>
</select>



All times are GMT +1. The time now is 09:19 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.