分页样式源码
① Thinkphp分页样式CSS代码
新建一个thinkphp项目tp,入口文件如下:
2
在数据库think下新建表qq_game,结构如下:
3
新建一个控制器AdminAction.class.php,位置如图所示:
4
在此控制器下新建函数beauty_page,用于美化分页;
未设置自定义分页时,函数如图:
模板页:tp/App/Tpl/Admin/beauty_page.html , 内容如图:
分页结果如下:
thinkphp中通过分页类Page提供的方法setConfig,来修改分页的设置:
比如:在代码 $pg = new Page($count, $per_page); 后插入下面的分页设置代码:
此时,分页显示册搏察结果如下(其中的上一页、下一页被改变):
Page类提供的setConfig方法,还可以设置theme 作为分页主题描述信息。
设置该属性可以改变分页的各个单元的显示银拍位置,默认值是:
"%totalRow% %header% %nowPage%/%totalPage% 页 %upPage% %downPage% %first% %prePage% %linkPage% %nextPage% %end%"
可以通过改变该值的样式改变分页的样式。
比如:在列表页添加样式:如下:
结果显示如下:
也可以给记录总数添加样式,如图,给当前记录数,添加样式:
在模板州茄页添加样式,如图:
结果显示:
总结:可根据自己的爱好,自行添加样式,其中.pages a , .pages .current 是自带的,最好不要修改名称,可修改样式;如果不满意,可参考第11步,自行修改。
② 求asp分页代码,请给编剧一下下面的源码
已经完全给你写好了,请直接复制下面代码进行使用做橘谨(注纯基意,我的程序中所有的news.asp都要换成你的文件的文件名。如果你本页的文件名就叫news.asp的话就不用换啦)
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
set conn=server.createobject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.mappath("db_sousuo1.mdb")
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<伍信/head>
<body>
<table width="535" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="200" valign="top">
<%
dim rs,sql
set rs=server.CreateObject("adodb.recordset")
sql="select * from proct where "
if trim(request("bt"))<>"" then
sql= sql & "carclass like '%"&trim(request("bt"))&"%' and "
end if
if trim(request("nr"))<>"" then
sql= sql & "provice like '%"&trim(request("nr"))&"%' and "
end if
if trim(request("fbz"))<>"" then
sql= sql & "provice_shi like '%"&trim(request("fbz"))&"%' and "
end if
sql= sql & " 1=1 "
rs.open sql,conn,1
if rs.bof or rs.eof then
response.write "对不起,没有符合查询条件的学生信息!"
else
dim page
page=Clng(request("page"))
rs.pagesize=20
if page<1 then page=1
if page>rs.pagecount then page=rs.pagecount
rs.Absolutepage=page
%>
<%
for i=1 to rs.pagesize
%>
<table height=24 cellspacing=0 cellpadding=0 width=535 border=0>
<tbody>
<tr bgcolor="#f7f7f7" onmouseover="this.bgColor='#e8e8e8';" onmouseout="this.bgColor='#f7f7f7';">
<td height="25" align="left"><%=i%>. <%=rs("carclass")%></td>
</tr>
</tbody>
</table>
<%
rs.movenext
if rs.eof then exit for
next
end if
%></td>
</tr>
<tr>
<td>
<form name="form1" method="get" action="news.asp">
<%
Response.write "<span class='style1'>共找到</span>" & "<span class='style1'><font color='#FF0000'>" & Cstr(rs.RecordCount) & "</font></span>" & "<span class='style1'>名学生</span> "
if page<>1 then
response.write "<span class='style1'><a href=news.asp?page=1>首页</a> </span>"
response.write "<span class='style1'><a href=news.asp?page="&(page-1)&">上一页</a></span> "
end if
if page<>rs.pagecount then
response.write "<span class='style1'><a href=news.asp?page="&(page+1)&">下一页</a> </span>"
response.write "<span class='style1'><a href=news.asp?page="&rs.pagecount&">尾页</a> </span>"
end if
%>
<span class='style1'>第<font color='#FF0000'><%=page%></font>页/共<font color='#FF0000'><%=rs.pagecount%></font>页 </span>
<input name="page" size="2" value="<%=page%>">
<INPUT id=image type=image src="images/go.gif" border=0>
</form>
</td>
</tr>
</table>
</body>
</html>
③ 如何解释asp分页提示的源代码
拜托,这是ASP.NET的代码。
可以先取一个记录集对象,再CONST一个每页显示数的变量MaxPerPage,然后再RS.MOVE MaxPerPage。然后再显示就行了。
注意一下传的页面的值,另外优化的时候也可以将select语句变成select top MaxPerPage,这样就节省服务器资源哦。不用的字段也不用显示,所用的字段返回就行了掘桐,代替*。
我可以给你一个ASP的分页代码,自己参照着ASP.NET改一下就可以用了。
<!--#include file="../kill/chkssn.asp" -->
<!--#include file="../kill/chkadm.asp" -->
<!--#include file="../pub/connec.asp" -->
<%
Dim Page,RSNum,Total,MaxPerPage,FileName
Page=Request.QueryString("page") '取页数
MaxPerPage=10
FileName="hits.asp"
Set RS = Server.CreateObject("ADODB.RecordSet") '打开数据库
SQLStr = "Select * from user_info order by u_hits desc"
RS.Open SQLStr,Conn,1,1
If RS.BOF AND RS.EOF Then
Response.Write("无数据")
RS.Close
Conn.Close
Response.End()
End If
RSNum=RS.RecordCount
RS.PageSize=MaxPerPage
If (RSNum mod MaxPerPage)=0 Then '判断总页数
Total=RSNum\MaxPerPage
Else
Total=RSNum\MaxPerPage+1
End If
If IsNumeric(Page) and Len(Page)>0 Then '判断是否为数字
Page=Int(Page)
Else
Page=1
End If
If Page>胡首Total or Page<1 Then '页数侦错
Page=1
End If
If Page=1 Then '设置RS第一条记录的位置
RS.MoveFirst
Else
RS.Move (Page-1)*MaxPerPage
End If
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<link href="../img/admin.css" rel="stylesheet"裤散数 type="text/css" />
</head>
<body bgcolor="#CCCCCC">
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0" id="images_add">
<tr>
<td height="35"></td>
</tr>
<tr>
<td height="77" align="left" valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<th height="39" align="center">导师点击量统计</th>
</tr>
<tr>
<td height="204" align="left" valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#FFFFFF">
<tr>
<th width="70" align="center" bgcolor="#CCCCCC">ID</th>
<th width="70" align="center" bgcolor="#CCCCCC">登录名</th>
<th width="70" height="30" align="center" bgcolor="#CCCCCC">真实姓名</th>
<th width="100" align="center" bgcolor="#CCCCCC">类别</th>
<th align="center" bgcolor="#CCCCCC">学科</th>
<th width="70" align="center" bgcolor="#CCCCCC">点击数</th>
<th width="70" align="center" bgcolor="#CCCCCC">修改人</th>
<th width="100" align="center" bgcolor="#CCCCCC">修改时间</th>
</tr>
<%
If not(RS.BOF and RS.EOF) Then
For i=1 To MaxPerPage
If RS.EOF Then Exit For
%>
<tr>
<td align="center" bgcolor="#CCCCCC"><%= RS("u_id") %></td>
<td align="center" bgcolor="#CCCCCC"><%= RS("u_login_name") %></td>
<td height="30" align="center" bgcolor="#CCCCCC"><a href="../users/teachers_edit.asp?id=<%= RS("u_id") %>"><%= RS("u_real_name") %></a></td>
<td height="30" align="center" bgcolor="#CCCCCC"><a href="../users/teachers_edit.asp?id=<%= RS("u_id") %>">
<% If RS("u_doctor")=True and RS("u_graate")=True Then %>
博硕双导师
<%
Else
If RS("u_doctor")=True Then
%>
博士生导师
<% End If %>
<% If RS("u_graate")=True Then %>
硕士生导师
<% End If %>
<% End If %>
</a></td>
<td height="30" align="center" bgcolor="#CCCCCC"><a href="../users/teachers_edit.asp?id=<%= RS("u_id") %>"><%= Left(RS("u_teach_major"),25) %></a></td>
<td align="center" bgcolor="#CCCCCC"><%= RS("u_hits") %></td>
<td align="center" bgcolor="#CCCCCC"><%= RS("u_edit_user") %></td>
<td align="center" bgcolor="#CCCCCC"><%= RS("u_edit_date") %></td>
</tr>
<%
RS.MoveNext
Next
End If
%>
<tr>
<td height="30" colspan="8" align="center" bgcolor="#CCCCCC"><%
If Page=1 and Total=1 Then '只有一页
%>
首页上一页下一页尾页第1/1页共<%= RSNum %>条记录
<%
End If
If Page=1 and Total>1 Then '首页
%>
首页上一页<a href="<%= FileName %>?page=<%= Page+1 %>">下一页</a><a href="<%= FileName %>?page=<%= Total %>">尾页</a>第<%= Page %>/<%= Total %>页共<%= RSNum %>条记录
<%
End If
If Page>1 and Total>1 and Page<>Total Then '中间页
%>
<a href="<%= FileName %>?page=1">首页</a><a href="<%= FileName %>?page=<%= Page-1 %>">上一页</a><a href="<%= FileName %>?page=<%= Page+1 %>">下一页</a><a href="<%= FileName %>?page=<%= Total %>">尾页</a>第<%= Page %>/<%= Total %>页共<%= RSNum %>条记录
<%
End If
If Page>1 and Page=Total Then '最后一页
%>
<a href="<%= FileName %>?page=1">首页</a><a href="<%= FileName %>?page=<%= Page-1 %>">上一页</a>下一页尾页第<%= Page %>/<%= Total %>页共<%= RSNum %>条记录
<%
End If
%>
</td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
<tr>
<td height="71"></td>
</tr>
</table>
</body>
</html>
<%
RS.Close
Conn.Close
%>
④ 求asp分页源代码
晕~~ 你不是吧
我给你闷拦写个吧
<%
rs.pagesize=3
pagecount=rs.pagecount
page=int(request.querystring("page"))
if page<1 then page=1
if request.querystring("page")="" then page=1
rs.absoultepage=page
%>
下面是用for实现每页的条数
<%
for i=1 to rs.pagesize
if rs.eof then exit for
%>
-----显示内容---
<%
rs.movenext
next
%>
<%
for i=1 to pagecount '这里就是1 2 3 4 5 6 7 8 9 10
你自己把不同的巧薯i的值加链孝罩者接就可以了
下一页就是page+1
上一页就是page-1
自己写完吧
%>