Forums
This topic is locked
SQL to filter by entry "Status"
Posted 16 Aug 2007 10:07:02
1
has voted
16 Aug 2007 10:07:02 Floris Kruger posted:
Hi all,I have the following code which displayes properties to let when searched for by "City/Town", "Suburb", "Type" and then between two "Rental" amounts. I would like to also include filtering by the "Status" field so that only approved entries will be displayed in a search. Any help will be much appreciated.
Here is the code:
<%
Dim Recordset1__varRental1
Recordset1__varRental1 = "0"
If (Request.Querystring("Rental1" <> "" Then
Recordset1__varRental1 = Request.Querystring("Rental1"
End If
%>
<%
Dim Recordset1__varRental2
Recordset1__varRental2 = "0"
If (Request.Querystring("Rental2" <> "" Then
Recordset1__varRental2 = Request.Querystring("Rental2"
End If
%>
<%
Dim Recordset1__varSuburb
Recordset1__varSuburb = "%"
If (Request.Querystring("Suburb" <> "" Then
Recordset1__varSuburb = Request.Querystring("Suburb"
End If
%>
<%
Dim Recordset1__varType
Recordset1__varType = "%"
If (Request.Querystring("Type" <> "" Then
Recordset1__varType = Request.Querystring("Type"
End If
%>
<%
Dim Recordset1__varCityTown
Recordset1__varCityTown = "%"
If (Request.Querystring("CityTown" <> "" Then
Recordset1__varCityTown = Request.Querystring("CityTown"
End If
%>
<%
Dim Recordset1
Dim Recordset1_numRows
Set Recordset1 = Server.CreateObject("ADODB.Recordset"
Recordset1.ActiveConnection = MM_Tolet_STRING
Recordset1.Source = "SELECT UserID, Photo, Status, When, Owner, CityTown, Suburb, Type, Bedrooms, Bathrooms, Available, Ownerphone, Rental, Description FROM Table1 WHERE Rental BETWEEN " + Replace(Recordset1__varRental1, "'", "''" + " AND " + Replace(Recordset1__varRental2, "'", "''" + " AND Suburb LIKE '" + Replace(Recordset1__varSuburb, "'", "''" + "' AND Type = '" + Replace(Recordset1__varType, "'", "''" + "' AND CityTown = '" + Replace(Recordset1__varCityTown, "'", "''" + "'"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()
Recordset1_numRows = 0
%>