PDA

Click to See Complete Forum and Search --> : ordering selection


micksterbooty
Feb 12th, 2001, 12:52 AM
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

Mark Sreeves
Feb 12th, 2001, 03:16 AM
try this:

<%@ 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>

micksterbooty
Feb 12th, 2001, 08:53 AM
<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

Mark Sreeves
Feb 12th, 2001, 09:16 AM
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)