DIV+CSS ASP分页显示
急求高手分四列四行显示大于16个图片下一页显示谢谢ASP代码如下<body><divid="bd"><li>热门产品</div><divid="bdse"><%id=Re...
急求高手
分四列 四行显示
大于16个图片下一页显示 谢谢
ASP代码如下
<body>
<div id="bd">
<li>热门产品
</div>
<div id="bdse">
<%
id=Request.QueryString("id")
set rs = server.CreateObject("adodb.recordset")
sql="select top 16 * from News order by ID desc"
rs.open sql,conn,1,3
do while not rs.eof
%>
<img src="<%=rs("Title")%>" width="215" height="180" class="img" />
<%
rs.movenext
loop
rs.close
set rs=nothing
%>
<div id="bdsww">
首 页 上一页 下一页 尾页
</div>
</div>
</body> 展开
分四列 四行显示
大于16个图片下一页显示 谢谢
ASP代码如下
<body>
<div id="bd">
<li>热门产品
</div>
<div id="bdse">
<%
id=Request.QueryString("id")
set rs = server.CreateObject("adodb.recordset")
sql="select top 16 * from News order by ID desc"
rs.open sql,conn,1,3
do while not rs.eof
%>
<img src="<%=rs("Title")%>" width="215" height="180" class="img" />
<%
rs.movenext
loop
rs.close
set rs=nothing
%>
<div id="bdsww">
首 页 上一页 下一页 尾页
</div>
</div>
</body> 展开
2个回答
展开全部
<div id="bdse">
<%
Dim title
Page = Trim(Request("Page"))
If Page ="" Or Not IsNumeric(Page) Then
Page = 1
Else
Page = Cint(Page)
End If
Page_Size = trim(Request("Page_Size"))
If Not IsNumeric(Page_Size) Or Page_Size = "" Then
Page_Size = 10
Else
Page_Size = Cint(Page_Size)
End IF
Set Rs = Server.CreateObject("Adodb.Recordset")
Sql = "Select * From news Order by id desc"
Rs.Open sql,conn,1,1
IF Not Rs.EOF Then
Rs.PageSize = Page_Size
IF Page > Rs.Pagecount Then Page = Rs.Pagecount
Rs.AbsolutePage = page
For i=1 To Rs.PageSize
'*****以下是您要添加代码的地方*****
%>
<img src="<%=Rs("Title")%>" width="215" height="180" class="img" />
<%
'*****以上是您要添加代码的地方*****
Rs.MoveNext
IF Rs.EOF Then
Exit For
End IF
Next
End IF
Rs.Close
Set Rs = Nothing
%>
<div id="bdsww"><%
Sql = "Select Count(*) From news "
Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.Open Sql,Conn,1,1
If Not Rs.Eof Then
num = Rs(0)
End If
Rs.Close
Set Rs = Nothing
pagestr = Fpages("",num,page,page_size)
Response.Write pagestr
%>
</div>
</div>
<%
'cs参数,用|分割开
'recordnum总记录数
'page 当前页数
'page_size 每页条数
Function Fpages(cs,recordnum,page,page_size)
dim m:m=3 '左右超过3个就省略
dim str:str=""
dim s1
dim
()
if instr(url,"?")>0 then
url=split(url,"?")(0)
end if
s1=split(cs,"|")
dim cs2:cs2=""
for i=0 to ubound(s1)
cs2=cs2&"&"&cstr(s1(i))&"="&request(cstr(s1(i)))
next
dim countpage
if recordnum mod page_size=0 then
countpage=recordnum\page_size
else
countpage=recordnum\page_size+1
end if
if page*1=1 then
str=str&"<span class=""disabled"">|<</span><span class=""disabled""><</span>"
else
str=str&"<a href="""&url&"?page=1"&cs2&""">|<</a><a href="""&url&"?page="&page-1&cs2&"""><</a>"
end if
dim s,e
if page-m>0 then s=page-m else s=1
if page+m<countpage then e = page+m else e = countpage
for i=s to e
if i*1=page*1 then
str=str&"<span class=""current"">"&i&"</span>"
else
str=str&"<a href="""&url&"?page="&i&cs2&""">"&i&"</a>"
end if
next
if page*1 < countpage*1 then
str=str&"<a href="""&url&"?page="&page+1&cs2&""">></a><a href="""&url&"?page="&countpage&cs2&""">>|</a>"
else
str=str&"<span class=""disabled"">></span><span class=""disabled"">>|</span>"
end if
' str=str&" 共 "&countpage&" 页"
if countpage<=0 then str = ""
Fpages=str
End Function
'得到当前页面的地址
Function GetUrl()
On Error Resume Next
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)
GetUrl = strTemp
End Function
%>
下面的Fpages和GetUrl为公共函数,把这两个放到一个公共文件中,供所有页面使用。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询