473,890 Members | 1,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

2 New Member
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 &Findhouse=Sear ch
- 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.QuerySt ring("Town")
varBeds % Request.QuerySt ring("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 3211
ilearneditonline
130 Recognized Expert New Member
When processing a form, your Request.QuerySt ring 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.QuerySt ring("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 Recognized Expert Specialist
When processing a form, your Request.QuerySt ring 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.QuerySt ring("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
2921
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 text boxes? What this script is suppose to do is change the value of a second drop down list based on the selection from the first. Then a value is chosen from the script generated drop down list in the
5
6533
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 values of another drop down. Let's use the car industry as an example. Lets say I am storing in a database the data and relationships between car make, car type, and car model. So the first drop down box would like all makes. Upon selecting...
4
1649
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 to filter on the current school year. They work seperatly, but not together. I would like a user, if they want, to be able to apply both filters at once -- (only a certain school year and only a certain student). Help?
2
2386
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 list. I know how to fill the data in the drop-down list. But i don't know how to pass this control to Com+. Do we need to pass like private FillList(Object e) {
3
11457
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 newly filtered data without having to create a new dataview each time. Is that possible? Also, do I need to attach the dataview to the combo box each time? if (AgencyCounties == null || sPropertyState.Text != prevPropertyState) {...
3
2487
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 becomes shorter & shorter for the user to choose a value from. For example, suppose the user wants to select the name "Michael" from the dop down list . So when he tabs over & reaches this drop down list, he types "Mi" , then all the names...
5
4235
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); System.Data.SqlClient.SqlCommand dbCommand1 = new System.Data.SqlClient.SqlCommand();
5
14063
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 on the call logs below. I want to be able to select a company in the drop down list and have it filter out all the other companys in the list below. Please Help Thanks in Advance.
14
18286
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 database to do what I want by following your instructions! I want to filter a drop down list based on the entry of another field - which is also a lookup field. There is a master table of schools, and I have two more tables - one for regions, and then...
0
11222
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10918
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10460
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9625
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8015
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6041
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4674
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4270
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3275
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.