Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

search find link to a value

Status
Not open for further replies.

lintow

Programmer
Nov 29, 2004
82
US
I have a datbase that has 4 fields firstname, lastname, ID and link

I want to search a person and get results of there links in that database.

The field (link) has a value that points to an excel file.

So when I search that person I get a value that should point to an excel file.

And I would like to download that excel file from the browser.

I know you can link a excel file to anything.
but for my case there will be multiple excel files. So I want to search for the person that has an excel file and then dwonload it.

Can this be done. Does anyone have an example.
 
sounds lke this will require 2 tables since a user can have more than 1 link, right now you have a "flat" database

so create tblUsers with id(autonumber), linkid(number), lastname(text), firstname(text)
and create a tblLinks with linkid(autonumber), links(hyperlink to excel file) and join the 2 tables

BSL

 
no need for 2 tables just your original setup was correct

ex.

lets say you have select which it pulling the records from your db and you looping through the recordset to display all the records just have the link -linked to the link column

ex.

while not rs.eof then
response.write "<a href="""&rs("link")&""">"&rs("firstname")&"</a><br>"
wend
 
so now you have a person associated to a excel file, each person can have their own excel file same way they have their own id (id column)
 
yes,

if that's the case then i can see that. i was looking at

"but for my case there will be multiple excel files"

thinking a user can have more than 1 spreadsheet thus a one to many relationship

BSL
 
got you,in that case you would be better off with 2 tables as bslintx said
 
just the structure should be different

tblpeople
id, fname, lname

linktable
id, userid, linkurl

then just store the persons id in the userid field, they can then have many excel links
 
all you have to do have your select statement something like this

i'm using mysql, so if my command is different then access bare with me

select concat(tblpeople.name,' ',tblpeople.lname) as tblpeople.fullname
from tblpeople
left join linktable
on linktable.userid=tblpeople.id
 
yes, had the relationship backwards...thanks for the correction

BSL
 
If I set this hyperlink in the table would it work.

Because when I do this nothing shows up to click on. It seems empty

Does any one know why

td width="27%"><a href="<%=(Recordset1.Fields.Item("excel_two").Value)%>"></a></td>
 
can you provide a link to your page so we can see what your talking about. and post the code for your page
 
This is a intranet site not internet

here is the code I have


<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/test.asp" -->
<%
Dim Recordset1
Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_test_STRING
Recordset1.Source = "SELECT * FROM tablelk"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<form name="form1" method="get" action="search.asp">
<div align="center">
<p>&nbsp; </p>
<table width="75%" border="1">
<tr>
<td width="27%"><a href="<%=(Recordset1.Fields.Item("excel_two").Value)%>"></a></td>
response.write "<a href="<%=(Recordset1.Fields.Item("excel_two").Value)%>"></a>
<td width="73%">&nbsp;</td>
</tr>
<tr>
<td height="24">&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
<p>&nbsp;</p>
</div>
</form>
<p>&nbsp;</p>
</body>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>
 
well of the back this line will not work first because its missing the asp delimiter tags <% %>

response.write "<a href="<%=(Recordset1.Fields.Item("excel_two").Value)%>"></a>

second reason - its out of the <td> which will not work
 
next problem - i'm not sure what this page is suppose to be doing but

if its suppose to list all your records your out of luck because you are missing the loop feature which will through the records

also you don't need the form tag here because there if not form submission going on
 
try somwthing like this and tell me if something happens now

Code:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/test.asp" -->
<%
sql= "SELECT * FROM tablelk"
set rs = MM_test_STRING.execute(sql)

if not rs.eof then
rows=rs.getrows
end if

rs.close
MM_test_STRING.close
set rs= nothing
set MM_test_STRING= nothing

%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
  <div align="center">
    <p>&nbsp; </p>
    <table width="75%" border="1">
      <tr>
        <td width="27%">&nbsp;</td>
        <td width="73%">&nbsp;</td>
      </tr>
<%
for i=lbound(rows,2) to ubound(rows,2)
%>	  
      <tr>
        <td height="24"><%=rows(0,i)%></td>
        <td>&nbsp;</td>
      </tr>
<%
next
%>	  
      <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
    </table>
  </div>

</body>
</html>
 
just testing it out. I don't need to show all of the records just the first on is fine.

I'm using dreamweaver to create the page.
here is the code one more time

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/test.asp" -->
<%
Dim Recordset1
Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_test_STRING
Recordset1.Source = "SELECT * FROM login"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()
Recordset1_numRows = 0
%>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<p>
<%
response.write "<a href="""&Recordset1("excel_two")&"</a>"
response.write "<a href="""&Recordset1("excel_two")&"</a><br>"
%>
</p>
<p> </p>
<p>&nbsp;</p>
</body>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>
 
when you put this

<%
response.write "<a href="""&Recordset1("excel_two")&"</a>"
response.write "<a href="""&Recordset1("excel_two")&"</a><br>"
%>

i'm assuming you have field in the table login called excel_two and it is not empty on the first record

also you would do that line like this

<%
response.write "<a href="""&Recordset1("excel_two")&""">test</a><br>"
response.write "<a href="""&Recordset1("excel_two")&""">test of same field</a>"
%>

 
It seems to work, but when I click on (test) it trys to open another page. and I get an error page can not be found.

I thought that once I click the link....it would download the file or just open it.

this is the URL. and it shows the excel file at the end

 
its because your are saving the absolute file locations

c://inetpub...

you should be saving the subfolders/filename.xls or just filname.xls

example

282423_L.xls in the field
then your url shoul look like this


 
and if you view the source of your browser it would look like this

<a href="282423_L.xls">test</a>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top