CLASSIC ASP,在表中的变量中使用超链接

时间:2018-04-10 21:43:25

标签: asp-classic

您好我有一个问题,我想在我的表中使用超链接作为变量,我尝试了这段代码,但它给出了错误

<%

set conn1 = server.createobject("adodb.connection")

conn1.open "provider = microsoft.ace.oledb.12.0;data source = C:\inetpub\wwwroot\web\database.accdb" 

set rs1 = server.createobject("ADODB.Recordset")
rs1.open " select cityID, city_img, city_name, city_population, city_description, city_link from city order by cityID", conn1

x = "<table border = 1 width=500><tr><th><th><th>Name<th>City Population<th>City Description<th>Show the list</tr>"
response.write x
rs1.movefirst

while not rs1.eof

   x = "<tr><td>" & "<td><img src=img\" & rs1("city_img") & " height=200 width=200>" & "<td>" &  rs1("city_name") & "<td>" & rs1("city_population") & "<br>" & "Million" & "<td>" & rs1("city_description") & "<td>" & "<a href=""" & rs1("city_link") & """>" & show list & "</a>""</tr>"
   response.write x
   rs1.movenext

wend
response.write "</table>"

rs1.close
conn1.close
set rs1 = nothing

%>

1 个答案:

答案 0 :(得分:1)

看起来您附近有语法错误:

"<a href=""" & rs1("city_link") & """>"

你的双引号正在逃避代码并尝试将其重新组合在一起,而不会使用&#39;&amp;&#39;符号

这应该解决它:

"<a href='" & rs1("city_link") & "'>"

我的猜测是你试图使用双引号,因为单引号是clasisc asp中的注释,但是你在这里是一个字符串,所以它被取出了等式。