欢迎光临
我们一直在努力

另类的[分页显示效果]?!-ASP教程,ASP应用

建站超值云服务器,限时71元/月

什么都不做,就是查询数据,一页显示多少条就查询多少条数据出来。这样的速度应该是很快的了吧?哈哈。。思路就是,给id值出来,使用此id值做下一页或上一页的查询条件,并且还要排序!!在这里查询结果排序也起了很重要的作用!!!!

示例代码如下:

<!–#include file="conn.asp"–>

<%

dim aflag,nowid,lastid,ishownum

ishownum=20 一页显示多少条记录

%>

<!doctype html public "-//w3c//dtd html 4.01 transitional//en"

"http://www.w3.org/tr/html4/loose.dtd">

<html>

<head>

<meta http-equiv="content-type" content="text/html; charset=gb2312">

<title>无标题文档</title>

<style type="text/css">

<!–

td {

font-family: "宋体";

font-size: 12px;

}

a:link {

font-family: "宋体";

font-size: 12px;

color: #999999;

text-decoration: none;

}

a:visited {

font-family: "宋体";

font-size: 12px;

color: #999999;

text-decoration: none;

}

a:active {

font-family: "宋体";

font-size: 12px;

color: #999999;

text-decoration: none;

}

a:hover {

font-family: "宋体";

font-size: 12px;

color: #ff9900;

text-decoration: underline;

}

–>

</style>

</head>

<body>

<table width="750" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#d5d5d5">

<tr bgcolor="#f3f3f3">

<td width="10%" height="25" bgcolor="#f3f3f3"><div align="center"><strong>序号</strong></div></td>

<td width="25%" height="25"><div align="center"><strong>电影名称</strong></div></td>

<td width="57%" height="25" bgcolor="#f3f3f3"><div align="center"><strong>电影url地址</strong></div></td>

<td width="8%" height="25"><div align="center"><strong>类型</strong></div></td>

</tr>

<%

call show_list

%>

<tr bgcolor="#f3f3f3">

<td height="20" colspan="4"><div align="right"><a href="index.asp?aflag=fir">[首页]</a>&nbsp;&nbsp;<a href="index.asp?aflag=pre&sid=<%=nowid%>">[上一页]</a>&nbsp;&nbsp;<a href="index.asp?aflag=nex&sid=<%=lastid%>">[下一页]</a>&nbsp;&nbsp;<a href="index.asp?aflag=end">[尾页]</a></div></td>

</tr>

</table>

</body>

</html>

<%

call closedatabase

sub show_list

dim lastflag,nowflag

dim arrayrow

aflag=request("aflag")

nowid=request("sid")

select case aflag

case "nex"

if nowid<>"" then

sql="select top "&ishownum&" id,name,url,type from [movie] where id>"&nowid&" order by id asc"

else

sql="select top "&ishownum&" id,name,url,type from [movie] order by id desc"

end if

case "pre"

if nowid<>"" then

sql="select top "&ishownum&" id,name,url,type from [movie] where id<"&nowid&" order by id desc"

else

sql="select top "&ishownum&" id,name,url,type from [movie]"

end if

case "end"

sql="select top "&ishownum&" id,name,url,type from [movie] order by id desc"

case else

sql="select top "&ishownum&" id,name,url,type from [movie]"

end select

set rs=conn.execute(sql)

lastflag=false

nowflag=false

if rs.eof then

rs.close

set rs=nothing

exit sub

end if

获取数据到一个二维数组

arrayrow=rs.getrows()

dim ifrom,ito,istep

if aflag="pre" or aflag="end" then

ifrom=ubound(arrayrow,2)

ito=0

istep=-1

else

ifrom=0

ito=ubound(arrayrow,2)

istep=1

end if

nowid=arrayrow(0,ifrom)

lastid=arrayrow(0,ito)

for i=ifrom to ito step istep

response.write " <tr bgcolor=""#fdfdfd"" style=""cursor:hand"" onmouseover=""this.style.background=#f3f3f3"" onmouseout=""this.style.background=#fdfdfd"">"

response.write " <td height=""20""><div align=""center"">"&arrayrow(0,i)&"</div></td>"

response.write " <td>"&arrayrow(1,i)&"</td>"

response.write " <td>"&arrayrow(2,i)&"</td>"

response.write " <td>"&arrayrow(3,i)&"</td>"

response.write " </tr>"

next

rs.close

set rs=nothing

end sub

%>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 另类的[分页显示效果]?!-ASP教程,ASP应用
分享到: 更多 (0)