首页 新闻 会员 周边 捐助

ASP分页问题

0
悬赏园豆:15 [待解决问题]

有个ASP页面,其中有一页数据列表下只有首页和下一页,没有上一页和尾页功能,如何最小改动给添加上这两个链接,谢谢!

<%@ Language=VBScript %>
<html>
<head>
<meta NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body text="#000000" leftmargin="0" topmargin="0">
<table align="center" border="0" cellPadding="0" cellSpacing="0" width="100%">
<tr height="66">
<td align="center" valign="bottom" class="tdTop">查询</td>
</tr>
<form id="frmQuery" name="frmQuery" action="Query.asp" method="post">
<tr>
<td align="center" valign="top">
<table WIDTH="80%" BORDER="0" CELLSPACING="1" CELLPADDING="1" align="center">
<tr align="center">
<td>
结束日期:<input id="txtDate" name="txtDate" class="inDate"><img id="imgBtn_Date" name="imgBtn_Date" border="0" height="18" src="images/imgbtn_Date.gif" style="CURSOR: hand" width="18" onclick="javascript:calendar('frmQuery.txtDate');" align="absMiddle" border="0" title="点击选择日期">
<input type="submit" value=" 查 询 " id="btnQuery" name="btnQuery" class="OperateButton">
<input type="button" value="搜索" id="btnFind" name="btnFind" class="OperateButton" onclick="window.document.location.href='query.asp'">
</td>
</tr>
</table>
</td>
</tr>
<tr align="center">
<td height="5"></td>
</tr>
</form>
</table>
<table align="center" width="60%" border="1" cellspacing="0" bordercolorlight="#4da6ff" bordercolordark="#f0f8ff" bgcolor="#f0f8ff">
<tr align="center">
<td width="40%">时间</td><td colspan="3">班次</td>
</tr>
<%'
set rsLog = server.CreateObject("ADODB.RecordSet")
strSql = "select log_no from MAIN where log_no like '" & Request.QueryString("station") & "%' "
QueryDate = Request.QueryString("QueryDate")
if QueryDate <> "" then strSql = strSql & " and to_char(log_date,'yyyy-mm-dd')<= '" & QueryDate & "'"

QueryDate = Request.form("txtDate")
if QueryDate <> "" then strSql = strSql & " and to_char(log_date,'yyyy-mm-dd')<= '" & QueryDate & "'"
strSql = strSql + " order by log_date desc"

'log_no格式为“K201612311”形式,最后一位是序号,有1、2、3
rsLog.Open strSql, DBConn
i = 10 '每页显示行数
savelogdate = ""
dim saveshift(5)
saveshift(1)=""
saveshift(2)=""
saveshift(3)=""

saveshift(4)=""
saveshift(5)=""

dim lognum ,condition
if station = "K" then
lognum = 3
else
lognum = 3
end if


dim temp1,temp2

do while not rsLog.eof
thelogno = rsLog("log_no")
thelogdate = mid(thelogno, 2, 4) & "-" & mid(thelogno, 6, 2) & "-" & mid(thelogno, 8, 2)


if thelogdate <> savelogdate then

i = i - 1
if i = 0 then exit do
if savelogdate <> "" then
for j=1 to lognum

if station = "K" then
condition = j
else
condition = j
end if

if saveshift(condition)<>"" then
thelogno1=saveshift(condition)
temp2 = mid(thelogno1, 2, 4) & "-" & mid(thelogno1, 6, 2) & "-" & mid(thelogno1, 8, 2)
if temp1 = temp2 then

response.write "<td width=20% align=center><a href="#">"

response.write ShiftTypeName(clng(mid(thelogno1,10))) & "</a></td>"
else
Response.Write "<td width=20% align=center>&nbsp;</td>"
end if
else
Response.Write "<td width=20% align=center>&nbsp;</td>"
end if
next
Response.Write "</tr>"
for j=1 to lognum: saveshift(j)="": next
end if
temp1 = thelogdate
savelogdate = thelogdate
response.write "<tr><td width=40% align=center>" & thelogdate & "</td>"
end if

if mid(thelogno,10)="1" then saveshift(1)=thelogno
if mid(thelogno,10)="2" then saveshift(2)=thelogno
if mid(thelogno,10)="3" then saveshift(3)=thelogno
if mid(thelogno,10)="4" then saveshift(1)=thelogno
if mid(thelogno,10)="5" then saveshift(2)=thelogno


rsLog.movenext
loop

for j=1 to lognum
if station = "K" then
condition = j
else
condition = j
end if
if saveshift(condition)<>"" then
thelogno1=saveshift(condition)
temp2 = mid(thelogno1, 2, 4) & "-" & mid(thelogno1, 6, 2) & "-" & mid(thelogno1, 8, 2)
if temp1 = temp2 then
response.write "<td width=20% align=center>"
response.write ShiftTypeName(clng(mid(thelogno1,10))) & "</td>"
else
Response.Write "<td width=20% align=center>&nbsp;</td>"
end if
else
Response.Write "<td width=20% align=center>&nbsp;</td>"
end if
next
Response.Write "</tr></table>"
%>
<div align="center" style="margin:5px">
<a href="Query.asp">第一页</a>&nbsp;

'问题:此处如何添加“上一页”

<%if not rsLog.eof then%>
<a href="Query.asp?&amp;querydate=<%=thelogdate%>">下一页</a>
<%end if%>

'问题:此处如何添加“尾页”

</div>

</body>
</html>

菜菜01的主页 菜菜01 | 初学一级 | 园豆:14
提问于:2017-01-02 17:47
< >
分享
所有回答(2)
0

逻辑控制呗。。难道这玩意儿还有写死的?

大师兄丶 | 园豆:843 (小虾三级) | 2017-01-02 21:42
0

你的query的分页没有写,应该是一个query计算总count,一个query代入当前页码和页长度查询当前页数据。

最后通过count及页长计算出总共多少页(尾页),上一页只是一个逻辑控制(当前页码大于一则由前一页)。

ps,你sql这样拼接有注入风险

Daniel Cai | 园豆:10424 (专家六级) | 2017-01-03 09:16

大神:帮我改改吧,我不懂VB语句,领导又催,SQL先不管,谢谢!

支持(0) 反对(0) 菜菜01 | 园豆:14 (初学一级) | 2017-01-03 10:09

@菜菜01: 。。。。你也懒的抽抽了吧。随便搜一下也能找到啊

http://www.jb51.net/article/19584.htm

支持(0) 反对(0) Daniel Cai | 园豆:10424 (专家六级) | 2017-01-03 10:25
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册