Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Aug 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ASP drop down list

    I created a dropdown list populated with data from Access database using ASP. The following is the code:

    <select name="ID">
    <option></option>
    <%
    Do While Not objRS.EOF
    %>
    <option value="<%= objRS.Fields("ID") %>"><%= objRS.Fields("ADDRESS") %></option>

    <%
    objRS.MoveNext
    Loop
    %>
    </select>

    It successfully displays the data from the database in sequence order, sort by ID. As a result, the dropdown displays Address1 (ID=1) at the very top, follow by Address2 (ID=2) etc. However, I want to display the list in reverse order, which starts with the very last line in the databse then descending down to line 1. My SQL queries is just a very simple 'Select * from table' query.
    Can anyone please tell me what do I need to modify in the above code to reverse the display order? Do I also need to add the 'order by xx' query to the SQL query? Many thanks.

  • #2
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,172
    Thanks
    19
    Thanked 65 Times in 64 Posts
    Just add "order by id desc" to your query

  • #3
    Regular Coder
    Join Date
    Aug 2002
    Location
    USA
    Posts
    478
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Just add "order by id desc" to your query
    Way to go Nancy - a good answer in 10 words or less (seems like that's hard to do around here)!
    J. Paul Schmidt
    www.Bullschmidt.com - Freelance Web and Database Developer
    www.Bullschmidt.com/DevTip.asp - Classic ASP Design Tips


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •