djpazza
asked on
How do I return all results from my database from a querystring value?
Hi
I have a Listbox that filters my recordset by code e.g. FF, CL. The problem I have is that in the list box I want the user to be able to select 'ALL' to display all the records with all the different code from the dropdown. I'm sure I have have just passed '%' as the value before and this just brings up all the field but its not working.
Does this only work with number fields?
My URL string:
http://localhost/webs/report.asp?type=sale&datefrom=1-1-2008&dateto=5-2-2008&code=%&submit=filter
I have a Listbox that filters my recordset by code e.g. FF, CL. The problem I have is that in the list box I want the user to be able to select 'ALL' to display all the records with all the different code from the dropdown. I'm sure I have have just passed '%' as the value before and this just brings up all the field but its not working.
Does this only work with number fields?
My URL string:
http://localhost/webs/report.asp?type=sale&datefrom=1-1-2008&dateto=5-2-2008&code=%&submit=filter
<select name="code" id="code">
<option value="%">ALL</option>
<option value="CL">CL</option>
<option value="E">E</option>
ASKER
By passing the codes in the URL I can just see the matches from the database where the field code has the querystring code. I'm not using LIKE as I need it to be an extact match to the codes as some codes are simular to others.
Below is some sample data, I want to return all records with all codes.
My SQL statement:
SELECT *
FROM Cars INNER JOIN Car_models ON cars.model = car_models.id
WHERE type = 'MMCol5' AND code='MMCol6' AND dateadded >= datevalue('MMCol2') AND dateadded <= datevalue('MMCol3')
ORDER BY MMCol4 DESC
I'm using Dreamweaver so the MMCol values are just referenced to the request.querystring value.
Below is some sample data, I want to return all records with all codes.
My SQL statement:
SELECT *
FROM Cars INNER JOIN Car_models ON cars.model = car_models.id
WHERE type = 'MMCol5' AND code='MMCol6' AND dateadded >= datevalue('MMCol2') AND dateadded <= datevalue('MMCol3')
ORDER BY MMCol4 DESC
I'm using Dreamweaver so the MMCol values are just referenced to the request.querystring value.
CID CODE TYPE DATEADDED
1 CL sale 28/01/2008
2 E purchase 29/01/2008
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Forced accept.
Computer101
EE Admin
Computer101
EE Admin
On your script you could something like:
Dim code, qry
code = Request("code")
IF "%"=trim(code) Then
code = ""
End IF
qry = "SELECT * FROM Tablename where fieldname LIKE " & code & "%"
then query your db based on qry. If you have further questions. post your code.