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

    Limit MYSQL query to not show duplicates

    I am building a form that will include several options via a selection field.
    My MySQL is structured as follows.

    PHP Code:
    CREATE TABLE TUKO_support id INT(11NOT NULL auto_incrementmanuf varchar (100NOT NULL default ''url VARCHAR(100NOT NULL default ''name VARCHAR(100NOT NULL default ''PRIMARY KEY (id)) 
    I am using the following to fetch the data.

    PHP Code:
        <?php

    $query_supp 
    "SELECT manuf FROM TUKO_support ORDER BY manuf DESC" or die(mysql_error());
    $list mysql_query($query_supp) or die(mysql_error());
    $row_m mysql_fetch_assoc($list);

    ?>
    <form action="" method="get">
    <select name="manuf">
     <?php do { ?>
    <option><?php echo $row_m['manuf']; ?></option>
    <?php } while ($row_m mysql_fetch_assoc($list)); ?>
    </select>

    </form>
    My problem is it is very likely that the 'manuf' field will contain the same entry more than once. I do not need this to happen as my next query will use the selected 'manuf' var to fetch all the data from the 'url and 'name' fields from every row that has the same 'manuf' entry.

    How can I alter my query to limit this and stop the selection box from displaying the same data more than once ?

    Crowds
    PHP magpie | And President Of The Marmalade Atkins Fan Club | Crowds Design

  • #2
    Senior Coder koyama's Avatar
    Join Date
    Dec 2006
    Location
    Copenhagen, Denmark
    Posts
    1,246
    Thanks
    1
    Thanked 5 Times in 5 Posts
    How about this?
    PHP Code:
    "SELECT DISTINCT manuf FROM TUKO_support ORDER BY manuf DESC" 

  • #3
    Regular Coder
    Join Date
    May 2005
    Posts
    235
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks koyama !
    Quick reply, and it was exactly what I needed
    I should probably read the MySQL manual a bit more.

    Rep added for your speedy reply.

    Thanks again

    Crowds
    PHP magpie | And President Of The Marmalade Atkins Fan Club | Crowds Design


  •  

    Posting Permissions

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