Link to home
Start Free TrialLog in
Avatar of Webman04
Webman04Flag for United States of America

asked on

search via link: ASP Classic/VBScript/Access 2000/Dreamweaver CS3

Hi everyone, I have forgotten how to do a search via a link.  I want to have the following links for a boat site pull results from a database based on the length of the boat.   Each link would return that range of lengths.  Such as:

Boats 19ft to 25

Boats 26 to 36

Boats 37 ft and up

I already have the results pulling fine from a recordset but I need to filter the listing with the links above.

I want the website users to be able to click on one of these links to narrow down the selection of results.  How do I create the recordset using Dreamweaver CS3, Access, ASP Classic/VBScript

Also, how do I create the link to pull the results from the recordset.

Thanks
Avatar of Wayne Barron
Wayne Barron
Flag of United States of America image

I am thinking that you might want maybe a "Query"?

Lets say that your link is:    boats.asp?ft=19-25
Now. in your code you would do something like this:

<% if Request.QueryString("ft")="19-25" then %>
Information from Database here
<% end if %>

Now.
you can also do this:

Link =    boats.asp?id=1

<% if Request.QueryString("ft")<>", " then %>
information from database goes here
<% end if %>

This above will read the information from ANY QueryString and display the proper results
Into the information area.

Give them a try and if you need further example let me know.
But I will need to have some more information as to how your table is set up
And what you want displayed.

Good Luck
Carrzkiss
Avatar of Webman04

ASKER

Hi, thanks for your help.  Here are some more details so you can possibly explain what I'm doing wrong.  The code below works with the links at the bottom, but it's not exactly what I wanted.  As it is right now, it pulls information based on the url parameter >= ?  so if I put in 1 then the results are greater than or equal to 1, which gives me all records, so if I use the link

<a href="http://www.domainname.com/inventorytest2.asp?ft=19">19 ft

Then the results are all records with length of 19ft or greater, but I am trying to get a range such as 19-25 which would pull only boats that have a length of 19-25ft but I tried to enter this in the url and it did not work.  I tried:

<a href="http://www.domainname.com/inventorytest2.asp?ft=19-25">19-25 ft</a> with no luck.  I'm sure I'm missing something very obvious here.

 
 
Here's the main code:
 
 
<%
Dim rs_inventory__MMColParam
rs_inventory__MMColParam = "1"
If (Request.QueryString("ft") <> "") Then 
  rs_inventory__MMColParam = Request.QueryString("ft")
End If
%>
<%
Dim rs_inventory
Dim rs_inventory_cmd
Dim rs_inventory_numRows
 
Set rs_inventory_cmd = Server.CreateObject ("ADODB.Command")
rs_inventory_cmd.ActiveConnection = MM_BoatDealer_STRING
rs_inventory_cmd.CommandText = "SELECT * FROM Inventory WHERE BoatLength >= ? ORDER BY BoatLength ASC" 
rs_inventory_cmd.Prepared = true
rs_inventory_cmd.Parameters.Append rs_inventory_cmd.CreateParameter("param1", 200, 1, 255, rs_inventory__MMColParam) ' adVarChar
 
Set rs_inventory = rs_inventory_cmd.Execute
rs_inventory_numRows = 0
%>
 
 
Here's the links
 
<table width="100%" border="1">
          <tr>
            <td colspan="4"><div align="center">Select A Boat Length</div></td>
          </tr>
          <tr>
            <td><div align="center"><a href="http://www.domainname.com/inventorytest2.asp?ft=1">Under 19ft +</a></div></td>
            <td><div align="center"><a href="http://www.domainname.com/inventorytest2.asp?ft=19">19 ft </a>+</div></td>
            <td><div align="center"><a href="http://www.domainname.com/inventorytest2.asp?ft=30">30ft </a>+</div></td>
            <td><div align="center"><a href="http://www.domainname.com/inventorytest2.asp?ft=40">40ft </a>+</div></td>
          </tr>
        </table>
 
 
Thanks in advance.

Open in new window

I am working on another project right now for another EE Member.
If you can give me until tomorrow, (or early this coming morning, if I do not sleep all night)
 I will take a look at your issue ok?

Thanks for understanding.

Carrzkiss
can you perhaps upload a sample of your database, with some sample information in it?
If you do not want to upload your DB here, you can check out my profile and send it to my e-mail
(Cannot give emails in post, it is against EE Rules)

If I can look at your DB and it's structure with some live data in it, I will be able to better assist you in this issue.
Which I am sure will not take long at all to figure out, and I will probably be able to do it this evening
Before I go to bed if you can get it to me quick enough.

Carrzkiss
Hi, thanks, this is a sample of what I have as my database.
BoatsDB.mdb
Hi, can you still help me?  Don't have much time left, is there anyone else that can?
I am sorry.
Let me reveiw your database.
I will get back with you in a little while with a possible solution.

I am so sorry, I have been helping so many people the last few days that
I have gotten behind.

Sorry.
Oh, no problem at all, didn't mean to pressure you.  Just running out of time, thanks very much for all your help!!!
OK. before my Internet Connection goes down again.

Test/Demo page
http://www.pcitdad.com/Test/EE/Q_24145455/Q_24145455.asp?GetStart=1&GetEnd=19
Code
http://www.pcitdad.com/Test/EE/Q_24145455/Q_24145455.zip

Keep this in mind while using the code

 if you do a Query on Q_24145455.asp?GetStart=10&GetEnd=20 you will get all the Lengths from 11 - 19

This was a great learning experiance for me, to get this to do what I did.
have a good one.
Wayne
(Once again, sorry for it taking so long)
Hello Webman04.

Did the example do what you wanted?
Please let me know?

Carrzkiss
ASKER CERTIFIED SOLUTION
Avatar of Wayne Barron
Wayne Barron
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi, sorry I had to leave unexpectedly.  I viewed the code and did use part of it as a reference but I had to rebuild it to match Dreamweaver so I could continue using it within Dreamweaver.  Here is the code I ended up using so you can keep it as a reference and others can use it if they have a similar problem.  I would not have come to this conclusion without your help, thanks.

The following code uses this link setup: inventorytest6.asp?ft=1&ft2=20

All I did what create two params, ft and ft2, then a link: inventorytest6.asp?ft=1&ft2=20 for each range and it works perfectly.  It is also fully editable within Dreamweaver.  Thanks very much for your help and time, without it I would never have thought of this way.

<%
Dim rs_inventory__MMColParam
rs_inventory__MMColParam = "1"
If (Request.QueryString("ft") <> "") Then 
  rs_inventory__MMColParam = Request.QueryString("ft")
End If
%>
<%
Dim rs_inventory__MMColParam2
rs_inventory__MMColParam2 = "30"
If (Request.QueryString("ft2") <> "") Then 
  rs_inventory__MMColParam2 = Request.QueryString("ft2")
End If
%>
<%
Dim rs_inventory
Dim rs_inventory_cmd
Dim rs_inventory_numRows
 
Set rs_inventory_cmd = Server.CreateObject ("ADODB.Command")
rs_inventory_cmd.ActiveConnection = MM_BoatDealer_STRING
rs_inventory_cmd.CommandText = "SELECT * FROM Inventory WHERE BoatLength >= ? AND BoatLength <=? ORDER BY BoatLength ASC" 
rs_inventory_cmd.Prepared = true
rs_inventory_cmd.Parameters.Append rs_inventory_cmd.CreateParameter("param1", 200, 1, 255, rs_inventory__MMColParam) ' adVarChar
rs_inventory_cmd.Parameters.Append rs_inventory_cmd.CreateParameter("param2", 200, 1, 255, rs_inventory__MMColParam2) ' adVarChar
 
Set rs_inventory = rs_inventory_cmd.Execute
rs_inventory_numRows = 0
%>

Open in new window

Very helpful, and gave me lots of ideas for future projects.  Thanks
I created the code in ACCESS.
I hate the way DW distorts the code.
It really takes something simple and makes it into a garbled mess.

But, people like using it, and that is what it is there.

Did you read the information that I had requested within' the readme file?

have a good one and glad that you got it to work with your own project.
Carrzkiss
Hi, yes I did read that, but I cannot risk my client being contacted sorry.  How did you create the in Access?  
I can give you a reference though.
Your client would not be contacted.
I am building my Resume.
That is not contacting people, that is showing people what type of work that I have done.

have a good one.
Yes, but in order for me to do that I would need to give you the website of my client, which I cannot do.  You are the first to ask for something in return for advise on here.  Besides the code you gave me didn't work.  I already gave you 5 stars if you are looking for a reference I already said I would provide one.  I built a very large and complex website and you only provided a tiny part of code, I'm not giving you credit for the site.  I'd rather pay you.  
DID NOT WORK!!!!!!
What do you mean did not work?

I was not Asking for something, for doing something on here.
I just said that I am trying to build my Resume.

What do you mean it "Did not work"???
The code does exactly what you asked for.

I cannot beleive this.
I did not want credit for the entire site.
You know. I helped provide something for you, and you said you was unable to give
Me the information, that was fine.
You DID NOT have to start bashing my code.
That is wrong.
Yes, fine your are correct should not have busted on your code, sorry.  But I meant it would have worked in a different situation but did not work for mine.  I needed it to work within the code I had already built which contains complex Dreamweaver CS3 plugins and it was not possible.  I don't see why a reference from me is not good?  That is better than showing work, besides all you have to do is show them the code you gave me.  That works on your servers.  Good luck.
>>contains complex Dreamweaver CS3 plugins and it was not possible.

Webman04
This is the magic, this is what made the code work.
"SELECT * FROM Inventory WHERE BoatLength >= ? AND BoatLength <=? ORDER BY BoatLength ASC

Which is the same thing that I provided for you
"SELECT Inventory.BoatID, Inventory.BoatModel, Inventory.BoatYear, Inventory.BoatLength FROM Inventory WHERE (((Inventory.BoatLength)>"""& getLen &""") AND (Inventory.BoatLength)<"""& getFin & """)"

regardless of what you had to do to it to get it to work with your DW Code.
This is the magic.
And this is what makes it all WORK.

I am sorry that you feel that it did not help you.
If it did not, then you should not have used it.

Later webman04

To add in one more thing.
Using  wildcards in your SELECT Statement is not good for complexe code.
That is where DW messes up at.
Replace the
*
With the actual FieldNames.
Like what I provided for you, regardless of what DW wants to do.
If you follow everything that DW does, then you are not going to accomplish ASP Code work.

Reason:
When a Request is being made on a table, for just 1-Fieldname.
Using the wildcard *
The request will have to look through your entire table for the Fieldname.
To where if you provide the proper fieldname(s) that are being queried, then it is
FAST and Accurate.
Using *
Will slow you down, exspecially on large queries.

Good Luck.
OK, thanks bye.