OutFront Forums
     Home    Register     Search      Help      Login    

Follow Us
On Facebook
On Twitter
RSS
Via Email

Recent Posts
Todays Posts
Most Active posts
Posts since last visit
My Recent Posts
Mark posts read

Sponsors
Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.
Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.
Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

 

Search Code - Something Stinks!

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP, PHP, and Database >> Search Code - Something Stinks!
Page: [1]
 
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

(in reply to Mav44)
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

(in reply to ou812)
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

(in reply to Mav44)
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?????

(in reply to ou812)
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

(in reply to Mav44)
Mav44

 

Posts: 197
Joined: 6/25/2006
Status: offline

 
RE: Search Code - Something Stinks! - 10/3/2009 0:45:43   
Sorry, I have tried it both ways and that was one of my later efforts. The most current I have been working with looks like;

sa = request.form("sa")
searchstr = ("searchstr")
searchstr1 = ("searchstr1")
if sa = "sf" then
sql = "select * from db23 where b_distributor like '%" & searchstr & "%' and a_region like '%" & 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



Your Tag Line Is Right - Balck Holes Suck ! :)

(in reply to ou812)
Spooky

 

Posts: 26680
Joined: 11/11/1998
From: Middle Earth
Status: offline

 
RE: Search Code - Something Stinks! - 10/3/2009 4:15:47   
searchstr = ("searchstr")
searchstr1 = ("searchstr1")

Where is the request?

searchstr = request.form("searchstr")
searchstr1 = request.form("searchstr1")

Also, to have an "ALL" criteria. you will need to pass a wild card to the query if you have one criteria populated and the other one not.

_____________________________

If you arent part of the solution, then there is good money to be made prolonging the problem

Sp:)ky


(in reply to Mav44)
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.

(in reply to Mav44)
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>

(in reply to Mav44)
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>

(in reply to Mav44)
Page:   [1]

All Forums >> Web Development >> ASP, PHP, and Database >> Search Code - Something Stinks!
Page: [1]
Jump to: 1





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