473,387 Members | 1,771 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Asp + Dreamweaver - I cannot filter my dispalyed data from DB for a drop down list

In Dreaweaver I cannot filter my database results to display only specific data that is retrieved from mulptile drop down list on my search page. The drop down list selections are posted to my display page by GET. How do i write my sql code so to only display info where TOWN = "Town selected from list" AND BEDS ="No of Beds selected from list

My search page form is below

Expand|Select|Wrap|Line Numbers
  1. <form action="tsearchresults.asp" method="get" name="townSearchForm" id="townSearchForm">
  2.                    <select name="varBeds" id="varBeds">
  3.                                 <option value="%" >All</option>
  4.                                 <option value="1 Bedroom" >1 Bedroom</option>
  5.                                 <option value="2 Bedrooms" >2 Bedrooms</option>
  6.                                 <option value="3 Bedrooms" >3 Bedrooms</option>
  7.                                 <option value="4 Bedrooms" >4 Bedrooms</option>
  8.                                 <option value="5 Bedrooms" >5 Bedrooms</option>
  9.                                 </select>
  10.  
  11.  
  12.                    <select name="varTown" id="varTown">
  13.                               <option value="%">All</option>
  14.                                                         <option value="Augher">Augher</option>
  15.  
  16.                 <option value="Coalisland">Coalisland</option>
  17.                 <option value="Cookstown">Cookstown</option>
  18.                 <option value="Donaghmore">Donaghmore</option>
  19.                  <option value="Dromore">Dromore</option>
  20.  
  21.  
  22.                                                          </select>
  23.  
  24.         <input type="submit" name="Findhouse" id="Findhouse" value="Search" />
  25.  
  26.  
  27.  
  28.                 </form>
  29.  
When the page tsearchresults.asp (below) is displayed the url displays - http://localhost/tyrone/tsearchresults.asp?varBeds=%25&varTown=Augher&Find house=Search
- hence just the fiter of town for town = Augher. But all towns are displayed

I select Bindings and Recordset in dreamweaver on tserachresults page and in the advanced section -
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


My variables, default values and Run time values are as below - am i refering correctly to my values from the form
varTown % Request.QueryString("Town")
varBeds % Request.QueryString("Beds")
where Town and Beds are records in my database.

The asp code for this is below


Expand|Select|Wrap|Line Numbers
  1. <%
  2. Dim Recordset1__varBeds
  3. Recordset1__varBeds = "%"
  4. If (Request.QueryString("Beds") <> "") Then 
  5.   Recordset1__varBeds = Request.QueryString("Beds")
  6. End If
  7. %>
  8. <%
  9. Dim Recordset1__varTown
  10. Recordset1__varTown = "%"
  11. If (Request.QueryString("Town") <> "") Then 
  12.   Recordset1__varTown = Request.QueryString("Town")
  13. End If
  14. %>
  15.  
  16.  
  17. <%
  18. Dim Recordset1
  19. Dim Recordset1_numRows
  20.  
  21. Set Recordset1 = Server.CreateObject("ADODB.Recordset")
  22. Recordset1.ActiveConnection = MM_connTyrone_STRING
  23. Recordset1.Source = "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, "'", "''") + "'"
  24. Recordset1.CursorType = 0
  25. Recordset1.CursorLocation = 2
  26. Recordset1.LockType = 1
  27. Recordset1.Open()
  28.  
  29. Recordset1_numRows = 0
  30. %>
  31.  
  32.  
  33.  
  34. While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF))
  35.  
  36.  
  37. <%=(Recordset1.Fields.Item("Beds").Value)%> <%=(Recordset1.Fields.Item("Town").Value)%>         
  38.           <td valign="top" class="PropertyHeading"><%=(Recordset1.Fields.Item("Address").Value)%>

All values are displayed and not just search results


Any Help would be VERY MUCH APPRECIATED
Aug 2 '07 #1
2 3186
ilearneditonline
130 Expert 100+
When processing a form, your Request.QueryString or Request.Post should reference the name of the form field, not the name of the field in the database.

So where you are referencing Request.QueryString("Beds"), you will never find that in your querystring, because you dropdown box is named varBeds.

Try replacing this section....
Expand|Select|Wrap|Line Numbers
  1. <%
  2. Dim Recordset1__varBeds
  3. Recordset1__varBeds = "%"
  4. If (Request.QueryString("Beds") <> "") Then
  5. Recordset1__varBeds = Request.QueryString("Beds")
  6. End If
  7. %>
  8. <%
  9. Dim Recordset1__varTown
  10. Recordset1__varTown = "%"
  11. If (Request.QueryString("Town") <> "") Then
  12. Recordset1__varTown = Request.QueryString("Town")
  13. End If
  14. %>
With...
Expand|Select|Wrap|Line Numbers
  1. <%
  2. Dim Recordset1__varBeds
  3. Recordset1__varBeds = "%"
  4. If (Request.QueryString("varBeds") <> "") Then
  5. Recordset1__varBeds = Request.QueryString("varBeds")
  6. End If
  7. %>
  8. <%
  9. Dim Recordset1__varTown
  10. Recordset1__varTown = "%"
  11. If (Request.QueryString("varTown") <> "") Then
  12. Recordset1__varTown = Request.QueryString("varTown")
  13. End If
  14. %>
Aug 3 '07 #2
jhardman
3,406 Expert 2GB
When processing a form, your Request.QueryString or Request.Post should reference the name of the form field, not the name of the field in the database.

So where you are referencing Request.QueryString("Beds"), you will never find that in your querystring, because you dropdown box is named varBeds.
of course i always find it convenient to use the same name in the first place...

Jared
Aug 3 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Dan | last post by:
This is one that has me stumped and I need an expert's input. Any ideas why the values from the second script-generated drop down list isn't recognized by the script to add time values to the...
5
by: SirPoonga | last post by:
I think I'd have to do a combination of ASP and javascript to do this. What I want to do fill the first drop down box with values from a database query. Then based off that selection fill in the...
4
by: crispywafers | last post by:
Hi, Is it possible to filter ontop of the current filter being applied to records? This seems like it should be easy? I have two drop down boxes-- one to filter on a student's last name, one...
2
by: ramesh | last post by:
hi, I am using Com+ in my application. It will have InsertRecords,selectRecords,updateRecords function. In the Web Form i have Drop-down list. I want to select records from SQL and add it to this...
3
by: Vern | last post by:
The following code retrieves data into a dataset, and then creates a dataview with a filter. This dataview is then attached to a combobox. When the effective date changes, I would like to see the...
3
by: pmud | last post by:
Hi, I have a drop down list bound to a database thorugh a data reader. It reads the customer names from data reader. Now, I want the user to be able to type more than one alphabet & the list...
5
by: Vigneshwar Pilli via DotNetMonster.com | last post by:
string connectionString1 = "server=(local); user=sa;password=sa; database=sonic"; System.Data.SqlClient.SqlConnection dbConnection1 = new System.Data.SqlClient.SqlConnection(connectionString1);...
5
by: Hutch | last post by:
Ok so i have a form that is in Continuous view displaying many "Call Logs" A drop down box is located in the header of the form. This box isalready set up to look at the Companys that are designated...
14
by: mjvm | last post by:
HI, I have had a search for the answer to this question, but I can't transfer what I am reading to my database. I don't know enough about the language required, but have been able to get my...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.