}
else
{
statushtml ="<a href=\"" i ")\">" i "</a> "
}
}
}
}
document.getElementById("pagestatus").innerHTML=statushtml;
}
function previousPage()
{
if (page>1)
{
getList(page-1);
}
else
{
alert("已经是第一页了");
}
}
function nextPage()
{
if(page<ipagecount)
{
getList(page 1);
}
else
{
alert("已经到最后一页了");
}
} 字串6
function turnPage(p)
{
getList(p);
} 字串1
getList(1);
</script>
</head>
<body>
<div id="newsList"></div>
<div id="pagestatus"></div>
</body>
</html>
字串1
============================================================================= 字串8
建一个文件data.asp
注:这里我用的是ACCESS数据库,库名叫data.mdb,当然这个自己可以定义,库中表名为info字段分别是id(自动编号)、a、b、c、d(日期类型) 字串9
<%@ Language="VBSCRIPT" codepage="936" %>
<%
response.cachecontrol="no-cache"
response.addHeader "pragma","no-cache"
response.expires=-1
response.expiresAbsolute=now-1
response.contentType="text/xml"
'SQL数据库 Set conn=server.CreateObject("adodb.connection")
'sconn="driver={sql server};server=(local);uid=**;pwd=**;database=***"
'conn.open sconn
set conn=server.CreateObject("adodb.connection")
file=server.mappath("data.mdb")
conn.Open "driver={microsoft access driver (*.mdb)};"&"dbq="&file%>
<?xml version="1.0" encoding="gb2312" ?>
<%
dim iPagesize,rs,sSQL,iCurPage,ipresize,icount,ipagecount
icurpage=trim(request.QueryString("curpage")) 字串2
iPagesize=500 '页大小
set rs=server.createObject("adodb.recordset")
'rs.open "select count(id) from ca_news where status=1",conn,1,1
rs.open "select count(id) from info",conn,1,1
icount=rs(0) '总记录数
rs.close
字串5
ipagecount=int((icount-1)/iPagesize) 1 '总页数
if icurpage="" then
icurpage=1
else
icurpage=cint(icurpage)
end if
if icurpage<1 then
icurpage=1
end if
if icurPage>ipagecount then icurpage=ipagecount
ipreSize=(iCurPage-1)*ipagesize
if ipresize=0 then
sSQL="select * from info order by id desc"
else
' sSQL="select top "&ipagesize&" id,title,postdate,hits,htmlurl from news where status=1 and id not in (select top "&ipresize&" id from news where status=1 order by id asc) order by id asc"
sSQL="select top "&ipagesize&" * from info id not in (select top "&ipresize&" id from info order by id desc) order by id desc"
end if
rs.open sSQL,conn,1,1 字串2
%>
<data count="<%=icount%>" pagesize="<%=ipagesize %>" pagecount="<%=ipagecount%>">
<%
while not rs.eof
%>
<item id="<%=rs("id")%>">
<title><![CDATA[<%=rs("a")%>]]></title>
<htmlurl><![CDATA[<%=rs("b")%>]]></htmlurl>
<postdate><%=DateValue(rs("d")) %></postdate>
<hits><%=trim(rs("c")) %></hits>
</item>
<%
rs.movenext
wend
%>
</data>
<%
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
字串1
字串6

