asp分页

<HEAD>
<TITLE>在学课程</TITLE>
<script language=javascript>
//点击"[第一页]"时响应:
function PageFirst()
{
document.MyForm.CurrentPage.selectedIndex=0;
document.MyForm.CurrentPage.onchange();
}
//点击"[上一页]"时响应:
function PagePrior()
{
document.MyForm.CurrentPage.selectedIndex--;
document.MyForm.CurrentPage.onchange();
}
//点击"[下一页]"时响应:
function PageNext()
{
document.MyForm.CurrentPage.selectedIndex++;
document.MyForm.CurrentPage.onchange();
}
//点击"[最后一页]"时响应:
function PageLast()
{
document.MyForm.CurrentPage.selectedIndex=document.MyForm.CurrentPage.length-1;
document.MyForm.CurrentPage.onchange();
}
//选择"第?页"时响应:
function PageCurrent()
{
document.MyForm.action='?CurrentPage='+(document.MyForm.CurrentPage.selectedIndex+1)
document.MyForm.submit();
}

</Script>

<!--#include file="../conn.asp"-->

<%
userid=session("user_id")
'userid=1
set rs=server.CreateObject("adodb.recordset") ''创建Recordset对象
''*设定一页内的记录总数,可根据需要进行调整
rs.PageSize=10
''*设置查询语句
StrSQL="Select DISTINCT cmesn_sp.sp_title,cmesn_sp_sort.sp_sort,cmesn_personsp.user_id,cmesn_sp.sp_length,cmesn_personsp.startdate, cmesn_personsp.sp_id from cmesn_personsp,cmesn_sp,cmesn_sp_sort,cmesn_user where cmesn_sp_sort.sp_sort_id=cmesn_sp.sp_sort_id and cmesn_personsp.sp_id=cmesn_sp.sp_id and complete=1 and cmesn_user.user_id=cmesn_sp.user_id and cmesn_personsp.user_id="&userid&" order by cmesn_personsp.startdate desc "
rs.Open StrSQL,conn,3,1,1
%>
</head>

<body>
<table width="590" height="90" border="1" align="center">
<tr>
<th width="90" height="29" scope="col">课程名称</th>
<th width="85" scope="col">课程类别</th>
<th width="89" scope="col">上传专家</th>
<th width="94" scope="col">视频时长</th>
<th width="84" scope="col">开始时间</th>
<th width="108" scope="col">操作</th>
</tr>
<%
IF rs.Eof THEN
page=0
Response.Write("<tr><td colspan=6 align=center><font size=2 color=#000080>数据库中暂无记录!</font></td></tr>")
ELSE
If Request("CurrentPage")="" or isempty(Request("CurrentPage")) Then
rs.AbsolutePage=1
page=1
else
rs.AbsolutePage=Clng(Request("CurrentPage"))
page=Clng(Request("CurrentPage"))
end If
for i=1 to rs.PageSize
%>
<tr>
<td height="28"><%=rs(0)%></td>
<td><%=rs(1)%></td>
<td><%=rs(2)%></td>
<td><%=rs(3)%></td>
<td><%=rs(4)%></td>
<td><a href="xuexi.asp?id=<%=rs(5)%>">观看<a><a href="jieke.asp?id=<%=rs(5)%>">结课</a></td>
</tr>
<%
rs.movenext
if rs.EOF then exit for
next
END IF
%>
<tr>
<td height="23" colspan="6"><div align="center">
<%
'设置翻页超链接
Response.Write("<form method='post' name='MyForm' >")
Response.Write("<p align=center><font size=2 color=#008000>")
if rs.PageCount=1 or page=0 then
Response.Write("[首页] [上一页] [下一页] [尾页] ")
else
if page=1 then
Response.Write("[首页] [上一页] ")
Response.Write("[<a href=javascript:PageNext()>下一页</a>] ")
Response.Write("[<a href=javascript:PageLast()>尾页</a>] ")
else
if page=rs.PageCount then
Response.Write("[<a href=javascript:PageFirst()>首页</a>] ")
Response.Write("[<a href=javascript:PagePrior()>上一页</a>] ")
Response.Write("[下一页] [尾页] ")
else
Response.Write("[<a href=javascript:PageFirst()>首页</a>] ")
Response.Write("[<a href=javascript:PagePrior()>上一页</a>] ")
Response.Write("[<a href=javascript:PageNext()>下一页</a>] ")
Response.Write("[<a href=javascript:PageLast()>尾页</a>] ")
end if
end if
end if
Response.Write("第<select size=1 name=CurrentPage onchange=PageCurrent()>")
For i=1 to rs.PageCount
if page=i then
Response.Write("<option selected>"&i&"</option>") ''当前页码
else
Response.Write("<option>"&i&"</option>")
end if
Next
Response.Write("</select>页/共"&rs.PageCount&"页 共"&rs.RecordCount&"条记录</font><p>")
Response.Write("</form>")

rs.close
set rs=nothing
conn.close
set conn=nothing
%>
</div></td>
</tr>
</table>
</body>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值