| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 536 人关注过本帖
标题:[求助]求助版主!分頁顯示出錯
只看楼主 加入收藏
冰琪
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2005-12-6
收藏
 问题点数:0 回复次数:0 
[求助]求助版主!分頁顯示出錯

查詢條件沒有空格時,分頁正常,查詢條件中有空格,則取得數據只有空格前的內容,分頁時查詢不到內容.
<div align="center">
<table class="tableframe" width="740">
<tr bgcolor="#D2FFD2"><td>廠商資料查詢</td></tr>
<tr class="listcelltitle">
<td class="listcelltitle">
<form name="form1" method="POST" action="factory.asp">
請選擇查詢方式:
<select size="1" name="selectm">
<option value="1">廠 商</option>
<option value="2">材 質</option>
</select> 關鍵字:<input type="text" name="selectkey" size="20" value=<%=request("selectkey")%>><input type="submit" value="查詢" name="B1"><input type="reset" value="重設" name="B2">&nbsp;&nbsp;當前時間為:<font color="#FF00FF"><%=formatdatetime(now(),2)%></font>
</form>
</td>
</tr>
</table>
<hr>
<% '開始分頁
Dim selectm,selectkey
session("selectm")=trim(request("selectm"))
session("selectkey")=trim(request("selectkey"))
selectm=session("selectm")
selectkey=session("selectkey")

Const MaxPerPage=15
dim totalPut
dim CurrentPage
dim TotalPages
dim sql
if Not isempty(request("page")) then
currentPage=Cint(request("page"))
else
currentPage=1
end if

if request("selectm")="1" then
sqlstr="select * from CSZL where CS_MC='"&selectkey&"' order by CS_IDD desc "
elseif request("selectm")="2" then
sqlstr="select * from CSZL where CS_CZ='"&selectkey&"' order by CS_IDD desc"
else
sqlstr="select * from CSZL"
end if
set rs=server.createobject("adodb.recordset")
rs.open sqlstr,conn,1,3
if rs.eof And rs.bof then
Response.Write "<p align='center' class='contents'> 數據庫中無數據!</p>"
else
totalPut=rs.recordcount

if currentpage<1 then
currentpage=1
end if

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
showContent
showpage totalput,MaxPerPage,"factory.asp"
else
if (currentPage-1)*MaxPerPage<totalPut then
rs.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rs.bookmark
showContent
showpage totalput,MaxPerPage,"factory.asp"
else
currentPage=1
showContent
showpage totalput,MaxPerPage,"factory.asp"
end if
end if
end if

sub showContent
dim i
i=0%>

<table class="tableframe" width="740">
<tr class=listtitle>
<td class="listcelltitle" width="80" style="word-break:break-all;">名 稱</td>
<td class="listcelltitle" width="70" style="word-break:break-all;">聯絡人</td>
<td class="listcelltitle" width="70" style="word-break:break-all;">傳 真</td>
</tr>
<% do while not rs.eof %>
<tr class=listrow1>
<td class=listcellrow style="word-break:break-all;"><% = rs("CS_MC") %>
</td>
<td class=listcellrow style="word-break:break-all;"><% = rs("CS_LLR")%>
</td>
<td class=listcellrow style="word-break:break-all;"><% = rs("CS_FAX") %>
</td>
</tr>
<%i=i+1
if i>=MaxPerPage then Exit Do
rs.movenext
loop
rs.close
set rs=nothing%>
</table>
<%
End Sub

Function showpage(totalnumber,maxperpage,filename)
Dim n

If totalnumber Mod maxperpage=0 Then
n= totalnumber \ maxperpage
Else
n= totalnumber \ maxperpage+1
End If

Response.Write "<form method=Post action="&filename&"?selectm="&selectm&"&selectkey="&selectkey&">"
Response.Write "<p align='center' class='contents'> "
If CurrentPage<2 Then
Response.Write "<font class='contents'>首頁 上一頁</font> "
Else
Response.Write "<a href="&filename&"?page=1&selectm="&selectm&"&selectkey="&selectkey&" class='contents'>首頁</a> "
Response.Write "<a href="&filename&"?page="&CurrentPage-1&"&selectm="&selectm&"&selectkey="&selectkey&" class='contents'>上一頁</a> "
End If

If n-currentpage<1 Then
Response.Write "<font class='contents'>下一頁 尾頁</font>"
Else
Response.Write "<a href="&filename&"?page="&(CurrentPage+1)&"&selectm="&selectm&"&selectkey="&selectkey&" class='contents'>"
Response.Write "下一頁</a> <a href="&filename&"?page="&n&"&selectm="&selectm&"&selectkey="&selectkey&" class='contents'>尾頁</a>"
End If
Response.Write "<font class='contents'> 頁次:</font><font class='contents'>"&CurrentPage&"</font><font class='contents'>/"&n&"頁</font> "
Response.Write "<font class='contents'> 共有"&totalnumber&"筆記錄 "
Response.Write "<font class='contents'>轉到:</font><input type='text' name='page' size=2 maxlength=10 class=smallInput value="&currentpage&">"
Response.Write "&nbsp;<input type='submit' class='contents' value='GO' name='cndok'>&nbsp;&nbsp;<a href='toexcel.asp' target='_blank'>轉化為EXCEL檔案</a></form>"
End Function
%>
</div>
</body>

[此贴子已经被作者于2005-12-7 9:18:16编辑过]

搜索更多相关主题的帖子: 版主 option class name 
2005-12-06 18:44
快速回复:[求助]求助版主!分頁顯示出錯
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.084147 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved