Jump to content

Recommended Posts

I have a drop down menu that is dynamically populated from a MySQL database. It is very possible that the field will have repeat names. (e.g. the field is favorite fruit - several users choose apple)

 

On the back end where I am pulling the data, the drop down menu is dynamically populated, and will repeat apple as a choice if it appears more than once in the field.

 

How do I make it where the repeats are ignored?

Link to comment
https://forums.phpfreaks.com/topic/157097-solved-dynamic-drop-down-menu/
Share on other sites

Yep it is possible depending on how your DB is designed.

 

If you do have repeats (which if you do my bet is your DB is designed wrong) then you can use the DISTINCT keyword in MySQL on the field:

 

SELECT DISTINCT fruit FROM fruits WHERE somecondition = true

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.