Forums

ASP

This topic is locked

Link to a WHERE statement

Posted 08 Oct 2002 10:34:40
1
has voted
08 Oct 2002 10:34:40 John Gallagher posted:
I have an Events table with 4 categories in it, I want to have 4 links at the top of my Main Events page which use a Where clause to each category.
I could do this with 4 recordsets but I want to have the links create a Where statement to only show each cat on there own.

Basically when the user clicks on "Sport" they get only the sport events from today forward. Or clicking on "Music", they only gets music events.

Is this possible, Can I have some "IF" statements to do this.

Any help, Please.

Later,

Webcrafty

Replies

Replied 08 Oct 2002 15:21:23
08 Oct 2002 15:21:23 Owen Eastwick replied:
Set up a recordset on the events page with a SQL statement something like:

<%
varCategory = Request.QueryString("Category"
If varCategory = "" Then
varFilter = ""
Else
varFilter = " WHERE Category LIKE '" & varCategory & "'"
End If
%>
<%
.....
.....
RecordsetName.Source = "SELECT Whatever, AndTheRest FROM tableName" & varFilter
.....
.....
%>

By default all the categories will be shown.


Then set up the links:

<a href="ThisPage.asp?Category=Sport">Show only Sports events</a>
<a href="ThisPage.asp?Category=Music">Show only Music events</a>
etc...

Regards

Owen.

Multiple Parameter UD4 / Access 2000 Database Search Tutorial:
www.tdsf.co.uk/tdsfdemo

Reply to this topic