Re: Hyperlinks From Database
What problem exactly do you have. Can you post some sample code for us to look at?
Thanks.
Re: Hyperlinks From Database
Here is the code (I have just taken the code between the body tags)
Code:
<table width="100%" border="0">
<tr valign="top">
<td width="21%"><!-- #include file="nav/left.asp" --></td>
<td width="79%"><p><strong>Useful Links</strong></p>
<p><%
dim Conn
dim FilePath
dim SQL
Dim RsUser
'Connection to Database
Set Conn = Server.CreateObject("ADODB.Connection")
FilePath = Server.MapPath("db/database.mdb")
Conn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & FilePath & ";"
'SQL Query String
SQL = "Select * FROM links"
'Set the Recordset
Set RSUser = Conn.Execute (SQL)
'Print the Recordset
RSUser.movefirst
Do while not RSUser.EOF
Response.Write ("<P>")
Response.Write (RSUser("url")) 'the address of the website
response.write("<br>")
response.write (RSUser("text")) 'the title of the website
response.write("<br>")
response.write (RSUser("info")) 'info about website
Response.Write ("</a>")
Response.Write ("</p>")
RSUser.movenext
Loop
%></p>
<p> </p></td>
</tr>
</table>
<p> </p>
</body>
I understand what is wrong with the above code, it currently shows the 'url', 'text' and 'info' fields from the database and loops till all entries are shown.
Now I would like to make it so that the user only sees 'text' and 'info' and the link on 'text' is 'url' that is where I can't get it to work.
Re: Hyperlinks From Database
I have found it works if you store the URL without the http:// and use the below code.
Code:
RSUser.movefirst
Do while not RSUser.EOF
Response.Write ("<p>")
Response.Write ("<a href=" & chr(34) & "http://" & RSUser("url") & chr(34)& ">")
Response.Write (RSUser("text")) 'the title of the website
Response.Write ("</a>")
Response.Write ("<br>")
Response.Write (RSUser("info")) 'info about website
Response.Write ("</p>")
RSUser.movenext
Code suggested from a member of another forum.