这个是主程序:
<!--#include file=top2.asp-->
<!--#include file=conn.asp-->
<%
set rs=server.CreateObject("adodb.recordset")
if request("nclassid")<>"" then/判断从用户传来的是哪个歌手的ID即nclassid
sql="select * from musiclist where nclassid="&request("nclassid")
end if
if not isempty(request("page")) then
currentpage=cint(request("page"))
else
currentpage=1
end if /这整个是判断显示第几页
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.Write"<p align='center'><br><br>Sorry,未找到你想要的歌手<br><br><a href="" javascript:history.go(-1)"">点此返回</a><br><br></p>"
else
totalput=rs.recordcount
maxperpage=10
pageurl="musiclist.asp"
if currentpage<1 then currentpage=1
if(currentpage-1)*maxperpage>totalput then
if (totalput mod maxperpage)=0 then
currentpage= totalput \ maxperpage
else
currentpage= totalput\maxperpage+1
end if
end if
if currentpage=1 then
showpage totalput,maxperpage,pageurl
musiclaist()
showpage totalput,maxperpage,pageurl
else
if (currentpage-1)*maxperpage<totalput then
rs.move (currentpage-1)*maxperpage
dim bookmark
bookmark=rs.bookmark
showpage totalput,maxperpage,pageurl/显示的是翻页的
musiclaist() /显示的是列出来的歌曲(调用这个函数:musiclaist())
showpage totalput,maxperpage,pageurl
else
currentpage=1
showpage totalput,maxperpage,pageurl
musiclaist()
showpage totalput,maxperpage,pageurl
end if
end if
end if /这部分是判断各种情况的显示
%>
这个是被调用的显示歌曲列表的 函数:
<center>
<table width="77%" border="0" style=" BORDER-top: #000000 1px solid">
<tr>
<td width="7%" align="center" valign="middle" backround= "/image/ll.gif">
<font size="2" face="宋体">选择</font></td>
<td width="42%" background="/image/ll.gif" ><font size="2" face="宋体">歌曲</font></td>
<td width="29%" background="/image/ll.gif" ><font size="2" face="宋体">歌手</font></td>
<td width="22%" background="/image/ll.gif" ><font size="2" face="宋体">试听</font></td>
</tr>
<%
set trs=server.CreateObject("adodb.recordset")
i=0
do while not rs.eof
i=i+1
tsql="select * from musiclist where nclassid="+cstr(rs("nclassid"))
trs.open tsql,conn,1,1
totalmnumber=trs.recordcount
trs.close
%>
<tr>
<td align="right" valign="middle" bgColor=#e7e3e7><font size="2" face="宋体">
<%=i%>.</font>
</td>
<td style="BORDER-RIGHT : #000000 1px solid ;BORDER-TOP : #000000 1px solid">
<a href="#" onclick="MM_openBrWindow('paly.asp?id=<%=rs("id")%>','','width=400,height=150')">
<font color="#000000" size="2" face="宋体" STYLE="Text-Decoration:none">
<%=rs("musicname")%></font>
</a>
</td>
<td style="BORDER-RIGHT : #000000 1px solid ;BORDER-TOP : #000000 1px solid">
<a href="musiclist.asp?nclassid=<%=request("nclassid")%>">
<font color="#000000" size="2" face="宋体" STYLE="Text-Decoration:none">
<%=rs("singer")%></font>
</a>
</td>
<td style="BORDER-ROGHT : #000000 1px solid;BORDER-TOP : #000000 1px solid">
<%if rs("wma")<>"" then%>
<a href="#" onclick="MM_openBrWindow('paly.asp?id=<%=rs("id")%>','','width=400,height=150')">
<img src="image/21.gif" width="33" height="13" border="0">
</a>
<%else
response.Write"<script>alert('未收录歌曲。');window.location.href='reg1.asp';</script>"
end if%></td>
</tr>
<%
if i>=maxperpage then exit do
rs.movenext
loop
end if
rs.close
else
response.Write"<script>alert('未收录歌曲。');window.location.href='index.asp';</script>"
end if
%>
</table>
</center>
<% end sub%>
这个是用于分页的函数:
<%
function showpage(totalnumber,maxperpage,filename)
dim n,page
if totalnumber mod maxperpage=0 then
n=totalnumber\maxperpage
else
n=totalnumber\maxperpage+1
end if
%>
<br><div align="center"><center>
<table width="95%" border="1" cellspacing="2" cellpadding="0" bordercolor="#56b0f4" bordercolordark="#ffffff">
<tr>
<form method="post" action="<%=filename%>?nclassid=<%=request("nclassid")%>">
<td bgcolor="#b4deef8" width="100%" align="center">
<font color="#000000" size="2" face="??ì?" >共找到</font>
<font color="<%=lertfcolor%>" ><b><%=totalnumber%></b></font>
<font color="#000000" size="2" face="??ì?" >项记录 分</font>
<strong><font color="<%=lertfcolor%>"><%=n%></font></strong>
<font color="#000000" size="2" face="??ì?" >页显示 当前第</font>
<strong><font color="<%=alertfcolor%>"><%=currentpage%></font></strong>
<font color="#000000" size="2" face="??ì?" >页</font>
<%if currentpage<2 then%>
<font color="#000000" size="2" face="??ì?" > 首页 上一页 </font>
<%else%>
<a href="<%=filename%>?page=1&nclassid=<%=request("nclassid")%>">
<font color="#000000" size="2" face="??ì?" >首页</font></a>
<a href="<%=filename%>?page=<%=currentpage-1%>&nclassid=<%=request("nclassid")%>">
<font color="#FF0000" size="2" face="??ì?" ><b>上一页</b> </font></a>
<%
end if
if n-currentpage<1 then
%><font color="#000000" size="2" face="??ì?" >下一页 末页</font>
<%else%>
<a href="<%=filename%>?page=<%=currentpage+1%>&nclassid=<%=request("nclassid")%>">
<font color="#FF0000" size="2" face="??ì?" ><b>下一页</b></font></a>
<a href="<%=filename%>?page=<%=n%>&nclassid=<%=request("nclassid")%>">
<font color="#000000" size="2" face="??ì?" >末页</font></a>
<%end if%></td></form>
</tr>
</table></center></div><br>
<%
end function
%>
<!--#include file=botton.asp-->