Jump to content

[SOLVED] Dynamic Drop Down Menu


spoco

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.