Results 1 to 4 of 4

Thread: ordering selection

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2001
    Posts
    22
    I want to give the user the option to order their database search:

    im trying the following not working:

    <select name ="order">
    <option value="price"> price</option>
    <option value="size"> size</option>
    <option value="date">date </option>

    var=request.form("order")

    SQL = "SELECT * FROM table ORDER BY 'var'"

    im a newbie is there a syntax problem???
    thanks
    mick

  2. #2
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    try this:
    Code:
    <%@ Language=VBScript %>
    <%option explicit%>
    <HTML>
    
    <%
    
    dim od
    dim strSQL
    
    	od=request("order")
    
    	
    
    strSQL = "SELECT * FROM table ORDER BY '" & od & "'" 
    'now use the sql string
    response.write strsql
    %>
     
    <BODY>
    <form action='yz.asp'>
    <select name ="order">
    <option value="price"> price</option>
    <option value="size"> size</option>
    <option value="date">date </option>
    </select>
    <input type=submit>
    </form>
    
     
    </BODY>
    </HTML>
    Mark
    -------------------

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Feb 2001
    Posts
    22

    still having trouble

    <select name ="order">
    <option value="price">price</option>
    <option value="size"> size</option>
    <option value="date">date </option>
    </select>



    dim od
    od=request.form("order")

    SQL ="SELECT * FROM table ORDER BY ' " & od & " ' "

    still having problems

  4. #4
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    I presume that this is going to be in an Active Server Page.

    If so, copy EXACTLY what I put above into a file.
    Make sure the file name matches that in the form's action (so it posts back to itself)
    Mark
    -------------------

Posting Permissions

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



Click Here to Expand Forum to Full Width