Results 1 to 5 of 5

Thread: asp vb sql newbie

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2001
    Posts
    22

    Unhappy

    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

  2. #2
    Fanatic Member Ianpbaker's Avatar
    Join Date
    Mar 2000
    Location
    Hastings
    Posts
    696
    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
    Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Feb 2001
    Posts
    22

    Wink

    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

  4. #4
    Fanatic Member Ianpbaker's Avatar
    Join Date
    Mar 2000
    Location
    Hastings
    Posts
    696
    This is what you need. the _ is just to include the string on the next line just use the following

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

    Ian
    Yeah, well I'm gonna build my own lunar space lander! With blackjack aaaaannd Hookers! Actually, forget the space lander, and the blackjack. Ahhhh forget the whole thing!

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Feb 2001
    Posts
    22
    cheers ian you are a legend.

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