Forum Moderators: open
I have a question on how to create links dynamically from an access db and post them on a page so the links are created automatically.
I have users search for policies based on key words, then the policy names are displayed. I can make them into links, but what I can't quite get is how to make them into links to the different policies without having to code every link to every page. I think that defeats the purpose. I am trying the 'hyperlink' setting in access, but I'm new at this.
I hope my description is understandable!
Thanks All!
I was trying this:
Repsonse.Write "<a href='<%objRec("Link")%>'"
and every variation I could think of and I am still having problems. I also tried your
solution and I have a question on syntax. The '=rs' in your post is something I have not seen before, but I am new at this still. Anyway, I tried both ways and I'm still missing something!
Thanks again for all your help
<% If a = "d" Then %>
<%
Dim objRec
Set objRec = Server.CreateObject("ADODB.Recordset")
objRec.Open "SELECT * FROM Policy WHERE PolName LIKE '" & t & "%'", "dsn=doctest"
Do While Not objRec.EOF
countup = countup + 1
objRec.MoveNext
Loop
If countup > 0 Then
Response.Write "<b>There have been " & countup & " matches.</b><p>"
objRec.MoveFirst
Do While Not objRec.EOF
Response.Write "<a href='<"%objRec("Link")%">'>" & objRec("PolName") & "</a>"
Response.Write "<b><i>" & objRec("PolId") & " " & objRec("PolDesc") & "<br /></i>"
objRec.MoveNext
Response.Write "<br /><br />"
Loop
Else
Response.Write "Sorry, no policies found!<p>"
End If
objRec.Close
Set objRec = Nothing%>
<% End If %>
Thanks for helping out!
I've been reading up on this, but it seems there are about 1000 ways to do the same thing and I can't tell which one pertains to my situation. I suspect my SELECT statement is not entirely right for what I am trying to do.
If countup > 0 Then
Response.Write "<b>There have been " & countup & " matches.</b><p>"
objRec.MoveFirst
Do While Not objRec.EOF
Response.Write "<a href=" & objRec("Link") & ">" & objRec("PolName") & "</a>"
Response.Write "<b><i>" & objRec("PolId") & " " & objRec("PolDesc") & "<br /></i>"
objRec.MoveNext
Response.Write "<br /><br />"
Loop
Else
Response.Write "Sorry, no policies found!<p>"
End If
Please post any errors you get.
<%
YOUR SQL SEARCH CODE GOES HERE
set rs=conn.execute(sql)
while not rs.eof
<a href = "http://yourwebaddress.com/policies.asp?id=<%=rs("yourUniqueRecordID")"><%= rs("policyName") %></a> <br>
<%
rs.movenext
wend
%>
the above will loop through your policies displaying the relevant ones and linking them to a generic policy page which you can then do this on that generic policy page....
CODE ON POLICY DISPLAY PAGE
<% policyID = request.querystring("id")
sql = "select * from policyTableName where yourUniqueRecordID = " & policyID
set conn=server.createobject("adodb.connection")
set rs=conn.execute(sql)
%>
then simply code in the fields on the page to display that policy to the user