|
| |
|
|
Mav44
Posts: 197 Joined: 6/25/2006 Status: offline
|
Search Code - Something Stinks! - 10/2/2009 13:42:42
I have 2 drop downs to pull data from my table at the same time and I am using the code below. It only pulls the first set of data. What have I missed. sa = request.form("sa")
searchstr = request.form("searchstr")
searchstr1 = request.form("searchstr1")
if sa = "sf" then
sql = "select * from db23 where b_distributor = '%" & searchstr & "%' and q_status = '%" & searchstr1 & "%' order by i_value DESC"
|
|
|
|
ou812
Posts: 1705 Joined: 1/5/2002 From: San Diego Status: offline
|
RE: Search Code - Something Stinks! - 10/2/2009 15:41:55
Your query looks pretty straight forward. Its not using the searchstr1? If so, maybe nothing is in it. Without seeing all the code it is hard to say. Try writing out your query so you know what it really looks like. Something like: if sa = "sf" then sql = "select * from db23 where b_distributor = '%" & searchstr & "%' and q_status = '%" & searchstr1 & "%' order by i_value DESC" response.write sql response.end
_____________________________
-brian Black Holes suck. EnterpriseDB: Enterprise-class relational database management system PostgreSQL: The world's most advanced open source database
|
|
|
|
Mav44
Posts: 197 Joined: 6/25/2006 Status: offline
|
RE: Search Code - Something Stinks! - 10/2/2009 18:08:43
Thanks for taking a look. There is plenty of date in both fields. The form I am using is <form method="POST" action="mymainpage.asp"><label>
<select name="searchstr" id="searchstr">
<option>Distributor</option>
<option value="ABC">ABC</option>
<option value="XYZ">XYZ</option>
</select>
</label> <label>
<select name="searchstr1" id="searchstr1">
<option>Status</option>
<option value="Won">Won</option>
<option value="Pending">Pending</option>
</select>
</label><input type="submit" value="Submit" c_name="B1"></p>
<input type="hidden" name="sa" value="sf"></form> The simplifed process I am using is sa = request.form("sa")
searchstr = request.form("searchstr")
searchstr1 = request.form("searchstr1")
if sa = "sf" then
sql = "select * from db23 where b_distributor = '%" & searchstr & "%' and q_status = '%" & searchstr1 & "%' order by i_value DESC"
else
sql = "select * from db23 where q_status = 'Pending' and a_region = 'asia' order by i_value DESC"end if Thanks again for any suggestions, I know it must be simple
|
|
|
|
ou812
Posts: 1705 Joined: 1/5/2002 From: San Diego Status: offline
|
RE: Search Code - Something Stinks! - 10/2/2009 22:16:47
Your form and ASP are straight forward. I'm thinking I'm not understanding what is or isn't working. When you're saying "It only pulls the first set of data" what do you mean by "it" is only pulling the first set of data? The drop down isn't populating? Or the query isn't pulling some sort of expected data. Sorry for my confusion.
_____________________________
-brian Black Holes suck. EnterpriseDB: Enterprise-class relational database management system PostgreSQL: The world's most advanced open source database
|
|
|
|
Mav44
Posts: 197 Joined: 6/25/2006 Status: offline
|
RE: Search Code - Something Stinks! - 10/2/2009 22:35:30
No problem, and thanks for your time. By "it" I mean the results. I am trying to use 2 drop downs to populate the return row. I want to be able to search for "cars" and "black" or "trucks" and "blue". I want to resuts to meet the criteria of both drop downs. Currently I put "cars" and "black" in my 2 drop downs and I get all cars and all rows are filling in. For some reason it only pays attention to the first drop down and skips the selected option in the second drop down. I hope this helps?????
|
|
|
|
ou812
Posts: 1705 Joined: 1/5/2002 From: San Diego Status: offline
|
RE: Search Code - Something Stinks! - 10/3/2009 0:34:37
I just noticed you're using "=" in your wildcard search. I believe you should be using "like" instead. I'm a little surprised it is returning results at all, but then maybe the engine is confused and returns the full set.
_____________________________
-brian Black Holes suck. EnterpriseDB: Enterprise-class relational database management system PostgreSQL: The world's most advanced open source database
|
|
|
|
Mav44
Posts: 197 Joined: 6/25/2006 Status: offline
|
RE: Search Code - Something Stinks! - 10/3/2009 12:06:08
Thanks Spooky but still not working. The search will work on the first drop down just fine. The problem is when the first drop down is not selected and the second drop down is selected this returns a blank page. I am wondering if this is because there is no value submitted to "searchstr". If I select both drop downs the results are only brought in by the first and no attention is paid to the second. My acutal form will not require a selection be made on all drop downs but I do need it to process all if several drop downs are selected.
|
|
|
|
Mav44
Posts: 197 Joined: 6/25/2006 Status: offline
|
RE: Search Code - Something Stinks! - 10/3/2009 12:44:02
I Got It Working! But now I have another question. Can I set the first drop down to a zero value in case nothing is selected and the form will only process the second value? Something Like this in the first drop down: <option value="0" selected>Distributor</option>
|
|
|
|
Mav44
Posts: 197 Joined: 6/25/2006 Status: offline
|
RE: Search Code - Something Stinks! - 10/3/2009 14:28:49
Save you guys the time. What I was loooking for is; <option value="""" selected>Distributor</option>
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|