...

View Full Version : Posting hyperlink from database



awayne
02-20-2003, 06:30 AM
I have a current search that allows you to select a specific state, forward to the next page and shows all dealers located in that state. What I would like to do is add dealers url link on that page. How do I go about posting a hyperlink. The link to the webpage is http://www.tiasdancewear.com/dealersearch.asp the way I would enter the data into the database is www.thesite.com Here is a snip of the code that I have so far:

end if
response.write("<td><a href=customerinfo.asp?customer=" &rsCustomers.Fields("customerID") & ">" & server.HTMLEncode (rsCustomers.Fields("customer")) & "</a></td>")
response.write("<td>" & server.HTMLEncode (rsCustomers.Fields("city")) & "</td>")
response.write("<td>" & server.HTMLEncode (rsCustomers.Fields("name")) & "</td>")
response.write("<td> "<a href=""&rsCustomers.Fields("link")">" "</a></td>")
response.write("</tr>")
row = row+1
rsCustomers.MoveNext
loop
response.write("</table>")
end if

All help is appreciated.

Thanks
Wayne

glenngv
02-20-2003, 08:41 AM
response.write("<td><a href=""" & rsCustomers.Fields("link") & """></a></td>")

awayne
02-20-2003, 05:00 PM
That cleared up the error that I was getting, thank you. Now it still is not posting the link on the page. Here is the link to the test search for this: http://www.tiasdancewear.com/dealersearchtesting2.asp I only have 1 url to test it under Alabama Not all dealers will have a url. Here is the code that I now have:
response.write("<td><a href=""" & rsCustomers.Fields("link") & """> " & server.HTMLEncode (rsCustomers.Fields("link")) & "</a></td>")

Thanks again for the help.

Wayne

glenngv
02-21-2003, 01:48 AM
strLink = rsCustomers.Fields("link")
if strLink<>"" and not isnull(strLink) then
response.write("<td><a href=""" & strLink & """>" & strLink & "</a></td>")
else
response.write("<td>No link</td>")
end if

awayne
02-21-2003, 03:34 AM
Thank you again... I added the code that you posted and it work BUT it is wanting to send me to http://www.tiasdancewear.com/www.testing.com I tried a few things that I though would work with no success. What do I need to add to make it just link to www.testing.com?

Thanks again,
Wayne

glenngv
02-21-2003, 03:48 AM
make it an absolute url by putting http:// in front of the url.

strLink = rsCustomers.Fields("link")
if strLink<>"" and not isnull(strLink) then
response.write("<td><a href=""http://" & strLink & """>" & strLink & "</a></td>")
else
response.write("<td>No link</td>")
end if

just make sure all the contents in the field "link" saved in the database does not start with http://
if it can contain that string, you can check it first:

strLink = rsCustomers.Fields("link")
if strLink<>"" and not isnull(strLink) then
if instr(1,strLink,"http://")=0 then strHttp = "http://" else strHttp=""
response.write("<td><a href=""" & strHttp & strLink & """>" & strLink & "</a></td>")
else
response.write("<td>No link</td>")
end if

awayne
02-21-2003, 03:56 AM
Thank you, worked perfectly. I was just missing a few "

Thanks
Wayne



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum