querystring problem

Results 1 to 3 of 3

Thread: querystring problem

  1. #1
    Join Date
    Dec 1969

    Default querystring problem

    Hi,<BR><BR>I am having trouble using a querystring to select products which fall into certain price bands.<BR><BR>For example I want to do an sql query that will display only products which are under £100<BR><BR>I am using a pull down menu to allow user to select a price range and the value is the query string e.g<BR><BR>newproductbyprice.asp?whichprice=&#060; 50&PageNo=1<BR><BR>and I call the querystring as so<BR><BR>price = Request.Querystring("whichprice") <BR><BR><BR>currently my select statement is <BR><BR>strSQL = "SELECT proprice,proid, prodname, prodman, prodimage, prodtext FROM swaggers WHERE proprice &#060;&#039%" & price & "%&#039"<BR><BR>If i do this only products with prices against them are shown. It doesn;t filter the database by the price e.g under £50.<BR><BR>hope you can<BR><BR>help<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: querystring problem

    just bouncing some ideas here.....<BR><BR>try using the sql BETWEEN statement e.g. WHERE proprice BETWEEN x AND y<BR><BR>could also try removing the % and &#039 and convert the string (presumably) price to a number with VAL(price)

  3. #3
    Franco Guest

    Default RE: querystring problem

    Dude,<BR><BR>it&#039s a friday, it&#039s late (in London town at least) and I&#039m answering ASP questions. Life&#039s peachy.<BR><BR>Mark, man, try these tips:<BR><BR>1. Make sure all your products have prices. Your SQL WHERE clause will skip null values (null &#060;&#062; 0).<BR><BR>2. Have your combo box options set up like this:<BR><BR>&#060;SELECT id=cboPrice name=cboPrice&#062;<BR>&#060;OPTION value="proprice&#060;50"&#062;Less than 50&#060;/OPTION&#062;<BR>&#060;OPTION value="proprice&#062;=50 and proprice&#060;100"&#062;Between 50 and 100&#060;/OPTION&#062;<BR><BR>etc. etc.<BR><BR>You can then have a SQL statement that looks like:<BR><BR>strSQL = "SELECT proprice,proid, prodname, prodman, prodimage, prodtext FROM swaggers WHERE " & Request.QueryString("cboPrice")<BR><BR>with the conditions being fed in by the combo box value via the querystring.<BR><BR>hth<BR><BR>Franco<BR><BR>cold, wet and hungry. buddy, can you spare an ASP site?

Posting Permissions

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