CLASSIC ASP,在 table 的变量中使用超链接
CLASSIC ASP, using hyperlink in a variable in table
你好,我有一个问题,我想在我的 table 中使用超链接作为变量,我尝试了这段代码,但它给出了错误
<%
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
%>
您似乎在附近有语法错误:
"<a href=""" & rs1("city_link") & """>"
您的双引号正在转义代码并试图在没有“&”符号的情况下将其放回原处。
这应该可以解决问题:
"<a href='" & rs1("city_link") & "'>"
我的猜测是你试图使用双引号,因为单引号是 clasisc asp 中的注释,但你在这里是一个字符串,所以它被排除在等式之外。
你好,我有一个问题,我想在我的 table 中使用超链接作为变量,我尝试了这段代码,但它给出了错误
<%
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
%>
您似乎在附近有语法错误:
"<a href=""" & rs1("city_link") & """>"
您的双引号正在转义代码并试图在没有“&”符号的情况下将其放回原处。
这应该可以解决问题:
"<a href='" & rs1("city_link") & "'>"
我的猜测是你试图使用双引号,因为单引号是 clasisc asp 中的注释,但你在这里是一个字符串,所以它被排除在等式之外。