ASP文章如何设置分页的问题 50
哪位高手帮我改成能分页显示的,当然方法越多越好。(记录集:nid编号,nbt标题,nnr内容,ndjs点击数,ntjtime添加时间。后台用的是ewebeditor编辑器...
哪位高手帮我改成能分页显示的,当然方法越多越好。(记录集:nid编号,nbt标题,nnr内容,ndjs点击数,ntjtime添加时间。后台用的是ewebeditor编辑器。注意喔,除分页的第一页,浏览后面的分页时,点击数不可以递增。
我只有50大洋,一并奉上了。
<%' IIf implementation
Function MM_IIf(condition, ifTrue, ifFalse)
If condition = "" Then
MM_IIf = ifFalse Else
MM_IIf = ifTrue End If End Function%>
<%Dim Recordset1__MMColParam
Recordset1__MMColParam = "1"
If (Request.QueryString("nid") <> "") Then
Recordset1__MMColParam = Request.QueryString("nid") End If%>
<%Dim Recordset1 Dim Recordset1_cmd Dim Recordset1_numRows
Set Recordset1_cmd = Server.CreateObject ("ADODB.Command")
Recordset1_cmd.ActiveConnection = MM_conn_STRING
Recordset1_cmd.CommandText = "SELECT * FROM news_biao WHERE nid = ?"
Recordset1_cmd.Prepared = true
Recordset1_cmd.Parameters.Append Recordset1_cmd.CreateParameter("param1", 5, 1, -1, Recordset1__MMColParam) ' adDouble
Set Recordset1 = Recordset1_cmd.Execute
Recordset1_numRows = 0%>
<%Set Command1 = Server.CreateObject ("ADODB.Command")
Command1.ActiveConnection = MM_conn_STRING
Command1.CommandText = "UPDATE news_biao SET ndjs = ndjs+1 WHERE nid = ?"
Command1.Parameters.Append Command1.CreateParameter("c", 3, 1, -1, MM_IIF(request("nid"), request("nid"), Command1__c & ""))
Command1.CommandType = 1
Command1.CommandTimeout = 0
Command1.Prepared = true
Command1.Execute()%>
<body>
<!--#include file="top.asp" -->
<table width="760" height="600" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="70" height="600" align="center" valign="top" bgcolor="#75DDFF"><p> </p>
<h1 class="STYLE1">新</h1>
<h1 class="STYLE1">闻</h1>
<h1 class="STYLE1">中</h1>
<h1 class="STYLE1">心</h1>
<p class="STYLE1"> </p></td>
<td width="580" align="center" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="6">
<tr>
<td align="center"><span class="STYLE3"><%=(Recordset1.Fields.Item("nbt").Value)%></span></td>
</tr>
<tr>
<td align="center"><span class="STYLE5">发布时间</span><%=(Recordset1.Fields.Item("ntjtime").Value)%> <span class="STYLE5"> 点击数<%=(Recordset1.Fields.Item("ndjs").Value)%></span></td> </tr>
<tr>
<td align="left" valign="top"><span class="STYLE5"><%=(Recordset1.Fields.Item("nnr").Value)%></span></td> </tr>
<tr>
<td align="center"> </td> </tr>
</table>
<br /></td>
</tr>
</table>
</body>
</html>
<%Recordset1.Close()
Set Recordset1 = Nothing%> 展开
我只有50大洋,一并奉上了。
<%' IIf implementation
Function MM_IIf(condition, ifTrue, ifFalse)
If condition = "" Then
MM_IIf = ifFalse Else
MM_IIf = ifTrue End If End Function%>
<%Dim Recordset1__MMColParam
Recordset1__MMColParam = "1"
If (Request.QueryString("nid") <> "") Then
Recordset1__MMColParam = Request.QueryString("nid") End If%>
<%Dim Recordset1 Dim Recordset1_cmd Dim Recordset1_numRows
Set Recordset1_cmd = Server.CreateObject ("ADODB.Command")
Recordset1_cmd.ActiveConnection = MM_conn_STRING
Recordset1_cmd.CommandText = "SELECT * FROM news_biao WHERE nid = ?"
Recordset1_cmd.Prepared = true
Recordset1_cmd.Parameters.Append Recordset1_cmd.CreateParameter("param1", 5, 1, -1, Recordset1__MMColParam) ' adDouble
Set Recordset1 = Recordset1_cmd.Execute
Recordset1_numRows = 0%>
<%Set Command1 = Server.CreateObject ("ADODB.Command")
Command1.ActiveConnection = MM_conn_STRING
Command1.CommandText = "UPDATE news_biao SET ndjs = ndjs+1 WHERE nid = ?"
Command1.Parameters.Append Command1.CreateParameter("c", 3, 1, -1, MM_IIF(request("nid"), request("nid"), Command1__c & ""))
Command1.CommandType = 1
Command1.CommandTimeout = 0
Command1.Prepared = true
Command1.Execute()%>
<body>
<!--#include file="top.asp" -->
<table width="760" height="600" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="70" height="600" align="center" valign="top" bgcolor="#75DDFF"><p> </p>
<h1 class="STYLE1">新</h1>
<h1 class="STYLE1">闻</h1>
<h1 class="STYLE1">中</h1>
<h1 class="STYLE1">心</h1>
<p class="STYLE1"> </p></td>
<td width="580" align="center" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="6">
<tr>
<td align="center"><span class="STYLE3"><%=(Recordset1.Fields.Item("nbt").Value)%></span></td>
</tr>
<tr>
<td align="center"><span class="STYLE5">发布时间</span><%=(Recordset1.Fields.Item("ntjtime").Value)%> <span class="STYLE5"> 点击数<%=(Recordset1.Fields.Item("ndjs").Value)%></span></td> </tr>
<tr>
<td align="left" valign="top"><span class="STYLE5"><%=(Recordset1.Fields.Item("nnr").Value)%></span></td> </tr>
<tr>
<td align="center"> </td> </tr>
</table>
<br /></td>
</tr>
</table>
</body>
</html>
<%Recordset1.Close()
Set Recordset1 = Nothing%> 展开
1个回答
展开全部
<%mykey=""
Const PAGESIZEs=20
Const PARTSIZE=10
page = request.querystring("page")
if page = "" or IsNull(page) then page = 1
if not IsNumeric(page) then page = 1
page = Cint(page)
set rs=server.CreateObject("adodb.recordset")
sql="select * from Hyd_Food order by Food_id desc "
rs.open sql,conn,1,1
recordcounts = rs.RecordCount
RS.PageSize = PAGESIZEs
pagecounts = RS.PageCount
if page < 1 then
page = 1
elseif page > pagecounts then
page = pagecounts
end if
If rs.Eof And rs.Bof Then
Response.Write("<tr><td colspan=6> <font color='red'><br><br>没有任何产品!<br><br></font></td></tr>")
Else
if recordcounts > 0 then RS.AbsolutePage = page
for i = 1 to PAGESIZEs
if RS.EOF then exit for
%>
<tr onmouseover="this.style.backgroundColor='#FF99FF';this.style.cursor='hand';" onmouseout="this.style.backgroundColor='';" title="产品名称:<%=rs("food_name")%>
" >
<td width="42" height="25" align="center"><%=rs("food_id")%></td>
<td width="120" height="25" align="center"><a href="<%=dir%>/Product/Product_Show.asp?Id=<%=Rs("food_id")%>" target='_blank'><%=hyd.LeftT(rs("food_name"),20)%></a></td>
<td width="101" align="center">
<%=conn.execute ("select title from hyd_food_type where id="&rs("food_bigid")&"")(0)%></td>
<td width="68" align="center"><%=rs("food_shopname")%></td>
<td width="81" height="25" align="center"><%=rs("food_price")%> 元/<%=rs("food_ptype")%></td>
<td width="100" height="25" align="center"><%=rs("food_zl")%> 折</td>
<td width="42" align="center"><%if rs("food_tj")=1 then response.Write "已推荐" else response.Write "未推荐" %></td>
<td width="50" align="center"><%if rs("food_show")=1 then response.Write "显示" else response.Write "不显示" %></td>
<td width="57" height="25" align="center"><%if rs("food_sh")=1 then response.Write "审核" else response.Write "未审核" %></td>
<td width="44" height="25" align="center"><a href="Food_edit.asp?id=<%=rs("food_id")%>">编辑</a></td>
<td width="45" height="25" align="center"><input name="doid" type="checkbox" id="doid" value="<%=rs("food_Id")%>" /></td>
</tr>
<% RS.MoveNext()
next
End If
%>
<%
if pagecounts > 0 then
response.write("<table width=""95%"" style=""margin-top:30px;"" align=center cellspacing=3 cellpadding=3><tr><td align=center>")
response.write("页次:<font color=red><b>" & page & "</font>/" & pagecounts & "</b> 每页<b>" & pagesizes & "</b>条 共<b>" & recordcounts & "</b>条 分页:")
Spage = page mod PARTSIZE
if page > PARTSIZE then
if Spage = 0 then Spage = PARTSIZE
Spage = page - Spage + 1
else
Spage = 1
end if
Epage = Spage + PARTSIZE - 1
if Epage > pagecounts then Epage = pagecounts
if page > 1 then response.write("[<a href=""?ser="&ser&"&searchname="&searchname&"&page=1"">首页</a>]")
if page > PARTSIZE then
response.write("<a href=""?ser="&ser&"&searchname="&searchname&"&page=" & Spage - 1 & """>[<<]</a>")
end if
for i = Spage to Epage
if i = page then
response.write("[<font color=red><b>" & i & "</b></font>]")
else
response.write("[<a href=""?ser="&ser&"&searchname="&searchname&"&page=" & i & """>" & i & "</a>]")
end if
next
if Epage < pagecounts then
response.write("<a href=""?ser="&ser&"&searchname="&searchname&"&page=" & Epage + 1 & """>[>>]</a>")
end if
if Epage <> pagecounts then response.write("[<a href=""?ser="&ser&"&searchname="&searchname&"&page=" & pagecounts & """>尾页</a>]")
response.write("</td></tr></table>")
end if
rs.close
%>
Const PAGESIZEs=20
Const PARTSIZE=10
page = request.querystring("page")
if page = "" or IsNull(page) then page = 1
if not IsNumeric(page) then page = 1
page = Cint(page)
set rs=server.CreateObject("adodb.recordset")
sql="select * from Hyd_Food order by Food_id desc "
rs.open sql,conn,1,1
recordcounts = rs.RecordCount
RS.PageSize = PAGESIZEs
pagecounts = RS.PageCount
if page < 1 then
page = 1
elseif page > pagecounts then
page = pagecounts
end if
If rs.Eof And rs.Bof Then
Response.Write("<tr><td colspan=6> <font color='red'><br><br>没有任何产品!<br><br></font></td></tr>")
Else
if recordcounts > 0 then RS.AbsolutePage = page
for i = 1 to PAGESIZEs
if RS.EOF then exit for
%>
<tr onmouseover="this.style.backgroundColor='#FF99FF';this.style.cursor='hand';" onmouseout="this.style.backgroundColor='';" title="产品名称:<%=rs("food_name")%>
" >
<td width="42" height="25" align="center"><%=rs("food_id")%></td>
<td width="120" height="25" align="center"><a href="<%=dir%>/Product/Product_Show.asp?Id=<%=Rs("food_id")%>" target='_blank'><%=hyd.LeftT(rs("food_name"),20)%></a></td>
<td width="101" align="center">
<%=conn.execute ("select title from hyd_food_type where id="&rs("food_bigid")&"")(0)%></td>
<td width="68" align="center"><%=rs("food_shopname")%></td>
<td width="81" height="25" align="center"><%=rs("food_price")%> 元/<%=rs("food_ptype")%></td>
<td width="100" height="25" align="center"><%=rs("food_zl")%> 折</td>
<td width="42" align="center"><%if rs("food_tj")=1 then response.Write "已推荐" else response.Write "未推荐" %></td>
<td width="50" align="center"><%if rs("food_show")=1 then response.Write "显示" else response.Write "不显示" %></td>
<td width="57" height="25" align="center"><%if rs("food_sh")=1 then response.Write "审核" else response.Write "未审核" %></td>
<td width="44" height="25" align="center"><a href="Food_edit.asp?id=<%=rs("food_id")%>">编辑</a></td>
<td width="45" height="25" align="center"><input name="doid" type="checkbox" id="doid" value="<%=rs("food_Id")%>" /></td>
</tr>
<% RS.MoveNext()
next
End If
%>
<%
if pagecounts > 0 then
response.write("<table width=""95%"" style=""margin-top:30px;"" align=center cellspacing=3 cellpadding=3><tr><td align=center>")
response.write("页次:<font color=red><b>" & page & "</font>/" & pagecounts & "</b> 每页<b>" & pagesizes & "</b>条 共<b>" & recordcounts & "</b>条 分页:")
Spage = page mod PARTSIZE
if page > PARTSIZE then
if Spage = 0 then Spage = PARTSIZE
Spage = page - Spage + 1
else
Spage = 1
end if
Epage = Spage + PARTSIZE - 1
if Epage > pagecounts then Epage = pagecounts
if page > 1 then response.write("[<a href=""?ser="&ser&"&searchname="&searchname&"&page=1"">首页</a>]")
if page > PARTSIZE then
response.write("<a href=""?ser="&ser&"&searchname="&searchname&"&page=" & Spage - 1 & """>[<<]</a>")
end if
for i = Spage to Epage
if i = page then
response.write("[<font color=red><b>" & i & "</b></font>]")
else
response.write("[<a href=""?ser="&ser&"&searchname="&searchname&"&page=" & i & """>" & i & "</a>]")
end if
next
if Epage < pagecounts then
response.write("<a href=""?ser="&ser&"&searchname="&searchname&"&page=" & Epage + 1 & """>[>>]</a>")
end if
if Epage <> pagecounts then response.write("[<a href=""?ser="&ser&"&searchname="&searchname&"&page=" & pagecounts & """>尾页</a>]")
response.write("</td></tr></table>")
end if
rs.close
%>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询