leeperman 0 Newbie Poster

My search page has form as below to pass data to tsearchresults.asp so that my database can be filter to display correct data.

<form action="tsearchresults.asp" method="get" name="townSearchForm" id="townSearchForm">
                    
                   <select name="varBeds" id="varBeds">
                                <option value="%" >All</option>
                                <option value="1 Bedroom" >1 Bedroom</option>
                                <option value="2 Bedrooms" >2 Bedrooms</option>
                                <option value="3 Bedrooms" >3 Bedrooms</option>
                                <option value="4 Bedrooms" >4 Bedrooms</option>
                                <option value="5 Bedrooms" >5 Bedrooms</option>
                                </select>
                              
                        
                   <select name="varTown" id="varTown">
                              <option value="%">All</option>
                                                        <option value="Augher">Augher</option>
                                                          
                <option value="Coalisland">Coalisland</option>
                <option value="Cookstown">Cookstown</option>
                <option value="Donaghmore">Donaghmore</option>
                 <option value="Dromore">Dromore</option>
              
               
                                                         </select>
                            
        <input type="submit" name="Findhouse" id="Findhouse" value="Search" />
                         
                      
                   
                </form>

When the page tsearchresults.asp is displayed the url displays - http://localhost/tyrone/tsearchresults.asp?varBeds=%25&varTown=Augher&Findhouse=Search - hence just the fiter of town for town = Augher. But all towns are displayed

I select all records from my table but cant figure out how to write my where statement to select the Town and Number of beds as passed from my search page

<%
Dim Recordset1__varBeds
Recordset1__varBeds = "%"
If (Request.QueryString("Beds") <> "") Then 
  Recordset1__varBeds = Request.QueryString("Beds")
End If
%>
<%
Dim Recordset1__varTown
Recordset1__varTown = "%"
If (Request.QueryString("Town") <> "") Then 
  Recordset1__varTown = Request.QueryString("Town")
End If
%>

my sql statement is

"SELECT DateAvailable, Address, Town, Postcode, Description1,  Let, PropertyType, Beds, Price, ID, DatePosted, Description2  FROM HouseDetails  WHERE  Beds like '" + Replace(Recordset1__varBeds, "'", "''") + "' AND Town like '" + Replace(Recordset1__varTown, "'", "''") + "'"

and i can display my records as below (for all of the table)

<%=(Recordset1.Fields.Item("Address").Value)%>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.