3 Replies Latest reply on Jul 31, 2007 8:47 AM by Newsgroup_User

    Dynamic Dropdown List PHP/MySQL

    destind4film Level 1
      I know this should be easier than it has become...I have even purchased two new books on PHP and Dreamweaver and I still am lost.

      I am trying to create a very basic search for a website. This search would be a category based search with a drop down menu only. There would also be an admin section that would allow for adding new records to the DB.

      So far I have created a basic admin page that submits the new records to the appropriate categories.

      I have created a basic search page with a Dynamic Drop Down and I have created a basic results page.

      So the problem I am having is that the Dynamic Drop Down List shows duplicate category names depending on how many records exist. Where it should only show single category names.

      Once selected, the results page is displayed and the records are displayed correctly using a dynamic table.

      Does anyone know what I need to do to change this dynamic list so that it doesn't display duplicate names???

      thanks.
        • 1. Re: Dynamic Dropdown List PHP/MySQL
          Level 7
          destind4film wrote:
          > So the problem I am having is that the Dynamic Drop Down List shows duplicate
          > category names depending on how many records exist. Where it should only show
          > single category names.

          SELECT DISTINCT category FROM mytable

          --
          David Powers, Adobe Community Expert
          Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
          Author, "PHP Solutions" (friends of ED)
          http://foundationphp.com/
          • 2. Re: Dynamic Dropdown List PHP/MySQL
            destind4film Level 1
            David,

            Can you please elaborate on how to do this. I saw that same answer in another post in the forums but I do not understand where this setting is.

            I have checked my phpmyadmin and there is an option for unique but it will not work for the categories in my DB because there are naturally multiple entries with the same category name associated.

            I also do not see this option anywhere in DW.

            Thanks.
            • 3. Re: Dynamic Dropdown List PHP/MySQL
              Level 7
              destind4film wrote:
              > Can you please elaborate on how to do this. I saw that same answer in another
              > post in the forums but I do not understand where this setting is.

              It's a very basic SQL query. The DISTINCT keyword after SELECT ensures
              that duplicate records are eliminated from the recordset.

              > I have checked my phpmyadmin and there is an option for unique but it will not
              > work for the categories in my DB because there are naturally multiple entries
              > with the same category name associated.

              UNIQUE is a type of index that forces a column to store only unique values.

              > I also do not see this option anywhere in DW.

              You won't. Dreamweaver provides the absolute basics for creating the
              code to work with a database. Unless you want to be severely limited in
              what you create, you need to learn some basic principles of database
              design and build your own SQL queries.

              To add DISTINCT to your basic SQL query, you need to click the Advanced
              button in the Recordset dialog box, and insert it in the SQL query by hand.

              --
              David Powers, Adobe Community Expert
              Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
              Author, "PHP Solutions" (friends of ED)
              http://foundationphp.com/