ASP怎么读取数据库内容的标题作为网页标题?
文章页面代码是:<!--#includefile="include/conn.asp"--><!DOCTYPEhtml><html><head><metahttp-equ...
文章页面代码是:
<!--#include file="include/conn.asp"--><!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>淄博友利机电设备有限公司</title><link href="css.css" rel="stylesheet" type="text/css"><script type="text/javascript" src="Carlder.js"></script></head><body><!--#include file="inc_header.asp"--><div id="Bodyer"> <div class="wrp_c"> <!--#include file="inc_left.asp"--> <div id="right"> <div class="right-t">新闻动态</div> <div class="right-c"> <div id="showContent"> <table width="92%" align="center" border="0" cellspacing="0" cellpadding="0"> <tr> <td valign="top" height="500"><% if request("nlt")="" then call news(request("None"),request("Ntwo")) else call shownews(request("nlt")) end if %></td> </tr> </table> </div> </div> </div> </div></div><!--#include file="inc_footer.asp"--></body></html>是这个 展开
<!--#include file="include/conn.asp"--><!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>淄博友利机电设备有限公司</title><link href="css.css" rel="stylesheet" type="text/css"><script type="text/javascript" src="Carlder.js"></script></head><body><!--#include file="inc_header.asp"--><div id="Bodyer"> <div class="wrp_c"> <!--#include file="inc_left.asp"--> <div id="right"> <div class="right-t">新闻动态</div> <div class="right-c"> <div id="showContent"> <table width="92%" align="center" border="0" cellspacing="0" cellpadding="0"> <tr> <td valign="top" height="500"><% if request("nlt")="" then call news(request("None"),request("Ntwo")) else call shownews(request("nlt")) end if %></td> </tr> </table> </div> </div> </div> </div></div><!--#include file="inc_footer.asp"--></body></html>是这个 展开
展开全部
是用id传过来的吗?也就是News.asp?showid=XXX的格式,如果是的话,在页面的最上面把id的值拿到,然后上数据库里面把这个ID对应的title再取出来就OK了,是这个逻辑,你会写吗?
<%
dim showid
showid = request.querystring("showid")
'判断showid
If showid = "" Or Not IsNumeric(showid) Then
Response.write "<script>alert('非法操作');history.back();</script>"
Response.End
End If
Dim articleTitle
set rs = server.createobject("adodb.recordset")
sql = "select * from jt_News where id="&showid
rs.open sql,conn,1,1
If rs.eof Then
rs.close
Set rs = Nothing
conn.close
Set conn = nothing
Response.write "<script>alert('非法操作');history.back();</script>"
Response.End
Else
articleTitle = rs("Title")
rs.close
Set rs = Nothing
End if
%>
取出来之后直接把title替换了就行
<title><%=articleTitle%></title>
<%
dim showid
showid = request.querystring("showid")
'判断showid
If showid = "" Or Not IsNumeric(showid) Then
Response.write "<script>alert('非法操作');history.back();</script>"
Response.End
End If
Dim articleTitle
set rs = server.createobject("adodb.recordset")
sql = "select * from jt_News where id="&showid
rs.open sql,conn,1,1
If rs.eof Then
rs.close
Set rs = Nothing
conn.close
Set conn = nothing
Response.write "<script>alert('非法操作');history.back();</script>"
Response.End
Else
articleTitle = rs("Title")
rs.close
Set rs = Nothing
End if
%>
取出来之后直接把title替换了就行
<title><%=articleTitle%></title>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询