PDA

Click to See Complete Forum and Search --> : asp vb sql newbie


micksterbooty
Feb 4th, 2001, 11:26 PM
hi all a total newbie here first week with this stuff.

I got a html form that passes info to asp page.
select name="price"
option value="200" $0-$200 /option
option value="400" $200-$400 /option
/select

SQL = "SELECT * FROM table WHERE price<"&Request.Form("price")&"

if select option value="400" it shows all items less than 400 when i only want to display items from 200-400.

Is this making sense. Do i need some vb script somewhere to make this work or is the SQL wrong

Cheers
newbie

Ianpbaker
Feb 5th, 2001, 06:18 AM
Hi micksterbooty

As long as the value's are always incrementing by 200 you can use the following

Dim selectvalue

selectvalue = Cint(Request.Form("price"))

SQL = "SELECT * FROM table " & _
"WHERE price>=" & (selectvalue - 200) & "AND price <= " & selectvalue

hope it helps

Ian

micksterbooty
Feb 5th, 2001, 09:35 AM
cheers ian it works a treat.

I tried adding another condition to the WHERE
but getting confused with syntax


SQL = "SELECT * FROM surfboardtable " & _
"WHERE price>=" & (selectvalue - 200) & "AND price <= " & selectvalue
AND state='"&Request.Form("state")&"'



thanks again
mick

Ianpbaker
Feb 5th, 2001, 09:47 AM
This is what you need. the _ is just to include the string on the next line just use the following


SQL = "SELECT * FROM surfboardtable WHERE price >= " & (selectvalue - 200) & " AND price <= " & selectvalue & " AND state='"&Request.Form("state") &"'"


Hope it helps

Ian

micksterbooty
Feb 5th, 2001, 10:23 PM
cheers ian you are a legend.