Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New Coder
    Join Date
    Sep 2012
    Thanked 0 Times in 0 Posts

    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">
    include 'config.inc';
    $query "SELECT * FROM browse";
    $result mysql_query($query) or die (mysql_error());
    $row mysql_fetch_array($result)) {

    ?><option><?php echo $row['category']; ?></option>
    Last edited by penny94; Nov 1st, 2012 at 04:14 AM.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts