主题:  分页显示留言[yoyo]

hdesign

职务:普通成员
等级:1
金币:0.0
发贴:11
注册:2004/9/16 13:45:44
#12004/11/7 8:42:45
<cfquery name="gb1" datasource="gbook">
select * from gbook order by id desc
</cfquery>

<!---定义分页变量--->
<cfset maxrows="5">
<cfparam name="url.startrow" default="1">
<cfif #url.startrow# is not "1">
<cfset UpRow=#url.startrow#-#maxrows#>
<cfelse>
<cfset UpRow="1">
</cfif>
<cfset DownRow=#url.startrow#+#maxrows#>
<cfif #DownRow# gt #gb1.recordcount#>
<cfset DownRow="#url.startrow#">
</cfif>
<cfif (#gb1.recordcount# mod #maxrows#) is 0>
<cfset lastrow=#gb1.recordcount#-#maxrows#+1>
<cfelse>
<cfset lastrow=(#gb1.recordcount#\#maxrows#)*#maxrows#+1>
</cfif>
<!---定义分页变量结束--->

<table border="1">
<tr>
<td>姓名</td>
<td>电子邮件</td>
<td>QQ号码</td>
<td>个人主页</td>
<td>留言内容</td>
<td>用户IP</td>
<td>留言日期</td>
</tr>
<cfoutput query="gb1" startrow="#url.startrow#" maxrows="#maxrows#">
<tr>
<td>#gb1.name#</td>
<td>#gb1.email#</td>
<td>#gb1.qq#</td>
<td>#gb1.homepage#</td>
<td>#gb1.content#</td>
<td>#gb1.ip#</td>
<td>#gb1.riqi#</td>
</tr>
</cfoutput>

</table>

<cfoutput>
<!---开始分页--->
<p align=left>
<input type=button value="第一页" class=btn onclick="javascript:location.href='main.cfm';">&nbsp;
<input type=button value="上一页" class=btn onclick="javascript:location.href='main.cfm?startrow=#uprow#';">&nbsp;
<input type=button value="下一页" class=btn onclick="javascript:location.href='main.cfm?startrow=#downrow#';">&nbsp;
<input type=button value="最后页" class=btn onclick="javascript:location.href='main.cfm?startrow=#lastrow#';">&nbsp;
</p>
<!---分页结束--->
</cfoutput>
示例:

图片如下:



网络白痴 | 5D荣誉斑竹

职务:普通成员
等级:4
金币:10.0
发贴:1657
注册:2001/1/5 16:32:35
#22004/11/7 10:10:01



s22

职务:版主
等级:4
金币:10.0
发贴:1634
注册:2004/12/19 13:06:46
#32005/3/17 10:31:10
分页还是用标签比较方便,用CFC是浪费功夫