hmdnawaz Posted January 17, 2011 Share Posted January 17, 2011 I have a dropdown list which have some elements. I want to get all the elements of the dropdown list into a variable of type array. Any Idea??? Quote Link to comment https://forums.phpfreaks.com/topic/224674-how-to-get-all-elements-of-a-dropdown-list-into-a-variable-of-type-array/ Share on other sites More sharing options...
Psycho Posted January 17, 2011 Share Posted January 17, 2011 I think you are going to have to try and explain more. Are you saying you have a form with a select list and you want the form to post all the values of the select list? If so, why? I would assume it is your code that created the select list so you should be able to logically determine the values that make up a select list. Plus, why have a select list of values if you don't want the user to select a value? Quote Link to comment https://forums.phpfreaks.com/topic/224674-how-to-get-all-elements-of-a-dropdown-list-into-a-variable-of-type-array/#findComment-1160552 Share on other sites More sharing options...
hmdnawaz Posted January 17, 2011 Author Share Posted January 17, 2011 I am calculating the values of dropdown list from the title field of the events table. As title field may contains same names in different rows. Suppose the title field contains "Meeting" in two different rows.Then in Meeting appears twice in my dropdown list and i want it to appears once as the name is same. Quote Link to comment https://forums.phpfreaks.com/topic/224674-how-to-get-all-elements-of-a-dropdown-list-into-a-variable-of-type-array/#findComment-1160583 Share on other sites More sharing options...
Psycho Posted January 17, 2011 Share Posted January 17, 2011 Ideally you would have a single table to describe the individual "titles" then in the events table you would reference the title for each record using a foreign key. But, there is a simple enough solutin using what you have. But, looking at your original question, I don't see any correlation in that request and your last response. Take the time to write a clear request and you will get better quality responses in a faster time. One solution is to simply create a query to return the distinct title values from your table SELECT DISTINCT title FROM events ORDER BY title Or the equivalent using GROUP BY SELECT title FROM events GROUP BY title ORDER BY title Quote Link to comment https://forums.phpfreaks.com/topic/224674-how-to-get-all-elements-of-a-dropdown-list-into-a-variable-of-type-array/#findComment-1160741 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.