Jump to content

How to get all elements of a dropdown list into a variable of type array???


hmdnawaz

Recommended Posts

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?

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.

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

 

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.