´Ë·½·¨ÊʺÏʹÓÃÐéÄâÖ÷»úµÄÅóÓÑ£¬ÊµÏÖЧ¹ûÀýÈç asp?id=1">www.xxxx.com/xx.asp?id=1 ÖØд³É www.xxxx.com/xx.asp?/1.html
Êý¾Ý¿âÊÇaccess£¬±íÃûarticle£¬ÀïÃæÓÐid£¬title£¬content
config.aspÁ¬½ÓÊý¾Ý¿âÎļþ
< %
'¹¦ÄÜ£ºaspʵÏÖα¾²Ì¬µÄÀý×Ó
'Êý¾Ý¿âÁ´½Ó
db="data.mdb"
Set conn = Server.CreateObject("ADODB.Connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(db)
conn.open connstr
If Err Then
err.Clear
Set conn = Nothing
Response.Write "Êý¾Ý¿âÁ¬½Ó³ö´í£¬Çë¼ì²éÁ¬½Ó×Ö´®¡£"
Response.End
End If
'¶¨ÒåÐÂÎÅÔĶÁ½çÃæµÄ¶ÁÈ¡
Dim News_title,News_content
Sub ReadNews()
set rs1=server.createobject("adodb.recordset")
sql1="select id,title,content from article where id="& ID
rs1.open sql1,conn,3,3
News_title=rs1("title")
News_content=rs1("content")
rs1.close
set rs1=Nothing
End Sub
% >
index.aspÐÂÎÅÁбíÒ³
< !--#include file="config.asp"-- >
<ol>
< %
Set rs=server.CreateObject("adodb.recordset")
sql="select * from Article"
rs.open sql,conn,1,1
do while not rs.eof
% >
<li><a href="http://www.xxxx.com/article.asp?/< %=rs("id")% >.html">< %=left(trim(rs("title")),30)% ></a>< >
< %
rs.movenext
loop
rs.close
set rs=Nothing
% >
</ol>
article.aspÐÂÎÅÄÚÈÝÒ³
< !--#include file="config.asp"-- >
< %
id=request.QueryString("id")
If id="" Then
server_v40=Request.ServerVariables("QUERY_STRING") //»ñÈ¡£¿ºǫ́µÄµØÖ·×Ö·û
id=Int(replace(replace(server_v40,"/",""),".html","")) //»ñÈ¡idÖµ
End If
Call ReadNews() //µ÷Óùý³Ì
% >
<div>
±êÌâ: <b>< %= News_title% ></b><br />
ÄÚÈÝ: < %=News_content% >
</div>