asp多条件查询分页不对
yyy=request("yyy")……ifyyy<>""thensql="select*fromwt2whereusername='"&yyy&"'orname='"&...
yyy=request("yyy")
……
if yyy <> "" then
sql="select * from wt2 where username='"&yyy&"' or name='"&yyy&"' or banji='"&yyy&"' order by fenshu desc"
else
sql="select * from wt2 order by fenshu desc"
end if
……
<a href="?page=1">首页</a>
<a href="?page=<%=epage-1%>">前一页</a>
<a href="?page=<%=epage+1%>">后一页</a>
<a href="?page=<%=rs.pagecount%>">末页</a> 展开
……
if yyy <> "" then
sql="select * from wt2 where username='"&yyy&"' or name='"&yyy&"' or banji='"&yyy&"' order by fenshu desc"
else
sql="select * from wt2 order by fenshu desc"
end if
……
<a href="?page=1">首页</a>
<a href="?page=<%=epage-1%>">前一页</a>
<a href="?page=<%=epage+1%>">后一页</a>
<a href="?page=<%=rs.pagecount%>">末页</a> 展开
2014-12-02 · 知道合伙人软件行家
yfcp
知道合伙人软件行家
向TA提问 私信TA
知道合伙人软件行家
采纳数:1748
获赞数:5544
有多年网站建设相关工作经验。熟悉ASP、ASP.net、VB、JavaScript、HTML等语言和CSS、Ajax等相关技术。
向TA提问 私信TA
关注
展开全部
<a href="?page=1&yyy=<%=yyy%>">首页</a>
<a href="?page=<%=epage-1%>&yyy=<%=yyy%>">前一页</a>
<a href="?page=<%=epage+1%>&yyy=<%=yyy%>">后一页</a>
<a href="?page=<%=rs.pagecount%>&yyy=<%=yyy%>">末页</a>
连接加上 yyy=<%=yyy%> 就可以了。要不然分页yy的参数传递不过去。
当然也可以判断一下yyy是否为空。
<%dim xxx
if yyy <> "" then xxx="&yyy="&yyy else xxx="" '如果yyy值不是空的,把参数赋值给xxx
%>
<a href="?page=1<%=xxx%>">首页</a>
<a href="?page=<%=epage-1%><%=xxx%>">前一页</a>
<a href="?page=<%=epage+1%><%=xxx%>">后一页</a>
<a href="?page=<%=rs.pagecount%><%=xxx%>">末页</a>
展开全部
ACCESS SQL 通用···
< %
''''''''''''''''''''''''''''''''''''
'' 功能完整的分页程序 + 高效SQL查询语句
'' Power by Love_Computer
'' love_computer@163.com
'' www.56390.com
'' 最后修改时间: 2005-05-26 12:28
'' 使用过程中有任何问题请跟贴,及时答复。
''''''''''''''''''''''''''''''''''''
TableName = "NewsInfo"
FieldName = " * "
SearchWhere = ""
OrderFieldName = "id"
OnlyFieldName = "id"
OrderType = 1
PageSizeNum = 10
Page = Trim(Request.QueryString("page"))
Call ShowTotalPage()
rsTotal = Session("rsTotal")
TotalPages = Session("TotalPages")
CurrentPage = Session("CurrentPage")
Session("rsTotal") = ""
Session("TotalPages") = ""
Session("CurrentPage") = ""
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''
PageSQL = GetPageSQL(TableName,FieldName,SearchWhere,OrderFieldName,OnlyFieldName,OrderType,PageSizeNum,CurrentPage)
'''显示分页
Call ShowPages(1,1,1)
'''''创建时间:2005-6-8 15:25 [love_computer@163.com]
''''' www.56390.com
'''''最后修改时间 14:21 2005-8-30
''''获取总页数,总记录数
Sub ShowTotalPage()
Rem 以下内容直接COPY调用,不用任何修改
If Page = "" or IsEmpty(Page) = True or Page = "0" or Page = Empty Then Page = 1
StrWhere = ""
If SearchWhere = "" Then
StrWhere = ""
Else
StrWhere = " WHERE " & SearchWhere
End If
StrTotal = "SELECT COUNT([" & OnlyFieldName & "]) AS [rsTotal] FROM [" & TableName & "] " & StrWhere
Set rsTotalRecord = Conn.Execute(StrTotal)
rsTotal = rsTotalRecord("rsTotal")
rsTotalRecord.Close:Set rsTotalRecord = Nothing
CurrentPage = Page
CurrentPage = Int(CurrentPage)
If rsTotal mod PageSizeNum = 0 Then
TotalPages = int(rsTotal \ PageSizeNum)
Else
TotalPages = int(rsTotal \ PageSizeNum) + 1
End If
If CurrentPage > TotalPages Then CurrentPage = TotalPages
Session("rsTotal") = rsTotal'总记录
Session("TotalPages") = TotalPages'总页数
Session("CurrentPage") = CurrentPage'当前页
End Sub
'''''''''''''显示分页信息
'' www.56390.com
Sub ShowPages(ShowListOrder,ShowSelect,ShowHidden)
If rsTotal <= PageSizeNum Then Exit Sub
StrURL = PageURL
If CurrentPage = 1 Then
PreviousPage = "首页 上页"
Else
PreviousPage = "<a href='" & StrURL & "1'>首页</a> <a href='" & StrURL & CurrentPage - 1 & "'>上页</a>"
End If
If CurrentPage = TotalPages Then
NextPage = "下页 末页"
Else
NextPage = "<a href='" & StrURL & CurrentPage + 1 & "'>下页</a> <a href='" & StrURL & TotalPages & "'>末页</a>"
End If
ShowPageNum = ""
If ShowListOrder = 0 Then
If CurrentPage > 5 Then
xx = CurrentPage - 4
yy = CurrentPage + 5
Else
xx = 1
yy = 10
End If
For ii = xx TO yy
If ii > TotalPages Then Exit For
ShowPageNum = ShowPageNum & " <a href='" & StrURL & ii & "'>["
If ii = CurrentPage Then ShowPageNum = ShowPageNum & "<font color='#FF0000'><b>"
ShowPageNum = ShowPageNum & ii
If ii = CurrentPage Then ShowPageNum = ShowPageNum & "</b></font>"
ShowPageNum = ShowPageNum & "]</a>"
Next
End If
ShowTotal = "共<font color='#FF0000'><b>" & rsTotal & "</b></font>条记录<font color='#FF0000'><b>"
If ShowListOrder = 1 Then
ShowTotal = ShowTotal & CurrentPage & "/"
End If
ShowTotal = ShowTotal & TotalPages & "</b></font>页"
ShowTable = "<table width='100%' border='0' cellspacing='0' cellpadding='0'>"
If ShowSelect = 0 Then
ShowTable = ShowTable & "<form name='page' method='get' action=''>"
End If
ShowTable = ShowTable & "<tr><td align='center' valign='middle'>"
ShowTable = ShowTable & PreviousPage & " " & ShowPageNum & " " & NextPage & " " & ShowTotal & " "
Response.Write ShowTable
If ShowHidden = 0 Then
Call ShowHiddenText()
End If
ShowTable = ""
If ShowSelect = 0 Then
ShowTable = ShowTable & "转到<select name='page' onchange='this.form.submit()'>"
For n = 1 TO TotalPages
ShowTable = ShowTable & "<option value='" & n & "'"
If n = CurrentPage Then ShowTable = ShowTable & " selected"
ShowTable = ShowTable & ">" & n & "</option>"
Next
ShowTable = ShowTable & "</select>页"
End If
ShowTable = ShowTable & "</td></tr>"
If ShowSelect = 0 Then
ShowTable = ShowTable & "</form>"
End If
ShowTable = ShowTable & "</table>"
Response.Write ShowTable
End Sub
'''''''获取完整URL
'' 来源于网上 好像是阿信的吧 具体不太清楚啦 HEHE
Function FullURL()
Dim strTemp
If LCase(Request.ServerVariables("HTTPS")) = "off" Then
strTemp = "http://"
Else
strTemp = "https://"
End If
strTemp = strTemp & Request.ServerVariables("SERVER_NAME")
If Request.ServerVariables("SERVER_PORT") <> 80 Then strTemp = strTemp & ":" & Request.ServerVariables("SERVER_PORT")
strTemp = strTemp & Request.ServerVariables("URL")
If Trim(Request.QueryString) <> "" Then strTemp = strTemp & "?" & Trim(Request.QueryString)
FullURL = strTemp
End Function
''''''''''获取URL - 分页专用
'''''''''' Power by Love_Computer...
'''''''''' www.56390.com
Function PageURL()
URL = FullURL
TempUrl = Split(URL,"?")
If ubound(TempUrl) = 0 then
URL = URL & "?page="
Else
TempUrl = Split(URL,"?page=")
If ubound(TempUrl) = 0 Then
TempUrl = Split(URL,"&page")
URL = TempUrl(0) & "&page="
Else
URL = TempUrl(0) & "?page="
End If
End If
PageURL = URL
End Function
''''''''''''分页SQL语句函数
Function GetPageSQL(TableName,FieldName,SearchWhere,OrderFieldName,OnlyFieldName,OrderType,PageSizeNum,Page)
'Power by Love_Computer 2005-05-26 12:28
' www.56390.com
StrWhere = ""
StrOrder = ""
StrSQL = ""
MaxMinID = ""
If SearchWhere = "" Then
StrWhere = ""
MaxMinID = " WHERE ( [" & OnlyFieldName & "] "
Else
StrWhere = " WHERE " & SearchWhere & " "
MaxMinID = " AND ( [" & OnlyFieldName & "] "
End If
If OrderType = 0 Then
MaxMinID = MaxMinID & " > ( SELECT MAX"
StrOrder = " ORDER BY [" & OrderFieldName & "] ASC "
Else
MaxMinID = MaxMinID & " < ( SELECT MIN"
StrOrder = " ORDER BY [" & OrderFieldName & "] DESC "
End If
If Page = 1 or Page = 0 Then
StrSQL = "SELECT TOP " & PageSizeNum & " " & FieldName & " FROM [" & TableName & "] " & StrWhere & StrOrder
Else
StrSQL = "SELECT TOP " & PageSizeNum & " " & FieldName & " FROM [" & TableName & "] " & StrWhere & MaxMinID
StrSQL = StrSQL & " ([" & OnlyFieldName & "]) FROM ( SELECT TOP "
StrSQL = StrSQL & PageSizeNum * (Page - 1) & " [" & OnlyFieldName & "] FROM [" & TableName & "] " & StrWhere & StrOrder
StrSQL = StrSQL & " ) AS TempTable ) ) " & StrOrder
End If
GetPageSQL = StrSQL
End Function
%>
< %
''''''''''''''''''''''''''''''''''''
'' 功能完整的分页程序 + 高效SQL查询语句
'' Power by Love_Computer
'' love_computer@163.com
'' www.56390.com
'' 最后修改时间: 2005-05-26 12:28
'' 使用过程中有任何问题请跟贴,及时答复。
''''''''''''''''''''''''''''''''''''
TableName = "NewsInfo"
FieldName = " * "
SearchWhere = ""
OrderFieldName = "id"
OnlyFieldName = "id"
OrderType = 1
PageSizeNum = 10
Page = Trim(Request.QueryString("page"))
Call ShowTotalPage()
rsTotal = Session("rsTotal")
TotalPages = Session("TotalPages")
CurrentPage = Session("CurrentPage")
Session("rsTotal") = ""
Session("TotalPages") = ""
Session("CurrentPage") = ""
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''
PageSQL = GetPageSQL(TableName,FieldName,SearchWhere,OrderFieldName,OnlyFieldName,OrderType,PageSizeNum,CurrentPage)
'''显示分页
Call ShowPages(1,1,1)
'''''创建时间:2005-6-8 15:25 [love_computer@163.com]
''''' www.56390.com
'''''最后修改时间 14:21 2005-8-30
''''获取总页数,总记录数
Sub ShowTotalPage()
Rem 以下内容直接COPY调用,不用任何修改
If Page = "" or IsEmpty(Page) = True or Page = "0" or Page = Empty Then Page = 1
StrWhere = ""
If SearchWhere = "" Then
StrWhere = ""
Else
StrWhere = " WHERE " & SearchWhere
End If
StrTotal = "SELECT COUNT([" & OnlyFieldName & "]) AS [rsTotal] FROM [" & TableName & "] " & StrWhere
Set rsTotalRecord = Conn.Execute(StrTotal)
rsTotal = rsTotalRecord("rsTotal")
rsTotalRecord.Close:Set rsTotalRecord = Nothing
CurrentPage = Page
CurrentPage = Int(CurrentPage)
If rsTotal mod PageSizeNum = 0 Then
TotalPages = int(rsTotal \ PageSizeNum)
Else
TotalPages = int(rsTotal \ PageSizeNum) + 1
End If
If CurrentPage > TotalPages Then CurrentPage = TotalPages
Session("rsTotal") = rsTotal'总记录
Session("TotalPages") = TotalPages'总页数
Session("CurrentPage") = CurrentPage'当前页
End Sub
'''''''''''''显示分页信息
'' www.56390.com
Sub ShowPages(ShowListOrder,ShowSelect,ShowHidden)
If rsTotal <= PageSizeNum Then Exit Sub
StrURL = PageURL
If CurrentPage = 1 Then
PreviousPage = "首页 上页"
Else
PreviousPage = "<a href='" & StrURL & "1'>首页</a> <a href='" & StrURL & CurrentPage - 1 & "'>上页</a>"
End If
If CurrentPage = TotalPages Then
NextPage = "下页 末页"
Else
NextPage = "<a href='" & StrURL & CurrentPage + 1 & "'>下页</a> <a href='" & StrURL & TotalPages & "'>末页</a>"
End If
ShowPageNum = ""
If ShowListOrder = 0 Then
If CurrentPage > 5 Then
xx = CurrentPage - 4
yy = CurrentPage + 5
Else
xx = 1
yy = 10
End If
For ii = xx TO yy
If ii > TotalPages Then Exit For
ShowPageNum = ShowPageNum & " <a href='" & StrURL & ii & "'>["
If ii = CurrentPage Then ShowPageNum = ShowPageNum & "<font color='#FF0000'><b>"
ShowPageNum = ShowPageNum & ii
If ii = CurrentPage Then ShowPageNum = ShowPageNum & "</b></font>"
ShowPageNum = ShowPageNum & "]</a>"
Next
End If
ShowTotal = "共<font color='#FF0000'><b>" & rsTotal & "</b></font>条记录<font color='#FF0000'><b>"
If ShowListOrder = 1 Then
ShowTotal = ShowTotal & CurrentPage & "/"
End If
ShowTotal = ShowTotal & TotalPages & "</b></font>页"
ShowTable = "<table width='100%' border='0' cellspacing='0' cellpadding='0'>"
If ShowSelect = 0 Then
ShowTable = ShowTable & "<form name='page' method='get' action=''>"
End If
ShowTable = ShowTable & "<tr><td align='center' valign='middle'>"
ShowTable = ShowTable & PreviousPage & " " & ShowPageNum & " " & NextPage & " " & ShowTotal & " "
Response.Write ShowTable
If ShowHidden = 0 Then
Call ShowHiddenText()
End If
ShowTable = ""
If ShowSelect = 0 Then
ShowTable = ShowTable & "转到<select name='page' onchange='this.form.submit()'>"
For n = 1 TO TotalPages
ShowTable = ShowTable & "<option value='" & n & "'"
If n = CurrentPage Then ShowTable = ShowTable & " selected"
ShowTable = ShowTable & ">" & n & "</option>"
Next
ShowTable = ShowTable & "</select>页"
End If
ShowTable = ShowTable & "</td></tr>"
If ShowSelect = 0 Then
ShowTable = ShowTable & "</form>"
End If
ShowTable = ShowTable & "</table>"
Response.Write ShowTable
End Sub
'''''''获取完整URL
'' 来源于网上 好像是阿信的吧 具体不太清楚啦 HEHE
Function FullURL()
Dim strTemp
If LCase(Request.ServerVariables("HTTPS")) = "off" Then
strTemp = "http://"
Else
strTemp = "https://"
End If
strTemp = strTemp & Request.ServerVariables("SERVER_NAME")
If Request.ServerVariables("SERVER_PORT") <> 80 Then strTemp = strTemp & ":" & Request.ServerVariables("SERVER_PORT")
strTemp = strTemp & Request.ServerVariables("URL")
If Trim(Request.QueryString) <> "" Then strTemp = strTemp & "?" & Trim(Request.QueryString)
FullURL = strTemp
End Function
''''''''''获取URL - 分页专用
'''''''''' Power by Love_Computer...
'''''''''' www.56390.com
Function PageURL()
URL = FullURL
TempUrl = Split(URL,"?")
If ubound(TempUrl) = 0 then
URL = URL & "?page="
Else
TempUrl = Split(URL,"?page=")
If ubound(TempUrl) = 0 Then
TempUrl = Split(URL,"&page")
URL = TempUrl(0) & "&page="
Else
URL = TempUrl(0) & "?page="
End If
End If
PageURL = URL
End Function
''''''''''''分页SQL语句函数
Function GetPageSQL(TableName,FieldName,SearchWhere,OrderFieldName,OnlyFieldName,OrderType,PageSizeNum,Page)
'Power by Love_Computer 2005-05-26 12:28
' www.56390.com
StrWhere = ""
StrOrder = ""
StrSQL = ""
MaxMinID = ""
If SearchWhere = "" Then
StrWhere = ""
MaxMinID = " WHERE ( [" & OnlyFieldName & "] "
Else
StrWhere = " WHERE " & SearchWhere & " "
MaxMinID = " AND ( [" & OnlyFieldName & "] "
End If
If OrderType = 0 Then
MaxMinID = MaxMinID & " > ( SELECT MAX"
StrOrder = " ORDER BY [" & OrderFieldName & "] ASC "
Else
MaxMinID = MaxMinID & " < ( SELECT MIN"
StrOrder = " ORDER BY [" & OrderFieldName & "] DESC "
End If
If Page = 1 or Page = 0 Then
StrSQL = "SELECT TOP " & PageSizeNum & " " & FieldName & " FROM [" & TableName & "] " & StrWhere & StrOrder
Else
StrSQL = "SELECT TOP " & PageSizeNum & " " & FieldName & " FROM [" & TableName & "] " & StrWhere & MaxMinID
StrSQL = StrSQL & " ([" & OnlyFieldName & "]) FROM ( SELECT TOP "
StrSQL = StrSQL & PageSizeNum * (Page - 1) & " [" & OnlyFieldName & "] FROM [" & TableName & "] " & StrWhere & StrOrder
StrSQL = StrSQL & " ) AS TempTable ) ) " & StrOrder
End If
GetPageSQL = StrSQL
End Function
%>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询