0

I am trying to make a drop down list that is populated by a sql database. The sql call is populating the list, but when I try to get the value= part it just doesn't work right.

I want its value= to be the location_id then what is displayed to the user to be the location_description. However, when I do the code below, the value= is the location_description and what is displayed to the user is the location_id. If i reverse the order, it doesn't help.

<select name="building" id="building">
            ~[tlist_sql;SELECT DISTINCT location_description, location_id FROM u_locations ORDER BY location_description]
                <option value="~(location_id)" >~(location_description)</option>
            [/tlist_sql]
            </select>

The result is:

 <select name="building" id="building">

                <option value="ADAM">1</option>

                <option value="ADMIN">0</option>

                <option value="BRON">12</option>

                <option value="CLA">3</option>

                <option value="CLATT">15</option>

                <option value="COQ">18</option>

                <option value="DAR">19</option>


            </select>

But I need it to be the reverse.

3 Answers 3

1

does this work ?

<select name="building" id="building">
        ~[tlist_sql;SELECT DISTINCT location_id,location_description FROM u_locations ORDER BY location_description]
            <option value="~(location_id)" >~(location_description)</option>
        [/tlist_sql]
        </select>

I just reversed the fields in the SELECT list

Sign up to request clarification or add additional context in comments.

Comments

0

Looks good to me. I would suspect there to either be:

  • The table actually contains the description in the location_id column
  • caching problems in either the web server or the browser.

Try restarting your web server and clearing your web cache in your browser.

Comments

0

As per w3schools documentation ORDER BY keyword sorts the records in ascending order by default

Simply to reverse, add ORDER BY location_description DESC

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.