【发布时间】:2012-10-03 13:26:38
【问题描述】:
我在 ColdFusion 页面上有以下代码。此页面显示来自以下查询的数据,每页有 25 条记录,分页。现在我需要提供一个文本框和搜索按钮,以便用户可以输入 positionid 并点击搜索....我在这里遇到的问题是,如果 positionid 在例如第 7 页中,如何显示第 n 页200 页。请指教。谢谢
<cfquery name="qry_postn_detail" datasource="mbtran">
select distinct position_id,schedule_group,accrual_profile,pay_rule_name,rest_days
from kronos_if.position_detail
order by position_id
</cfquery>
<cfset perpage = 25>
<cfparam name="url.start" default="1">
<cfif not isNumeric(url.start) or url.start lt 1 or url.start gt qry_postn_detail.recordCount or round(url.start) neq url.start>
<cfset url.start = 1>
</cfif>
<cfset totalPages = ceiling(qry_postn_detail.recordCount / perpage)>
<cfset thisPage = ceiling(url.start / perpage)>
<cfset thisPage = Int(start / 25) + 1>
Page<cfoutput>
<cfloop from="1" to="#totalPages#" index="i">
<cfif i is thisPage>
#i#
<cfelse>
<cfif totalPages lte 5 or i is 1 or i is totalPages or (i gt thisPage - 3 and i lt thisPage + 3) or ((thisPage is 1 or thisPage is 2) and i lt 6) >
<a href="?start=#(i*25)-24#">#i#</a>
<cfelse>
<cfif i is 2 or i is totalPages - 1>
...
</cfif>
</cfif>
</cfif>
</cfloop>
</cfoutput>
【问题讨论】:
-
您能否提供更多关于您希望它如何工作的详细信息?您提到添加用于搜索的文本框,但随后您说他们输入了特定的 positionid。您是想在搜索后再次显示所有结果还是只显示与他们搜索的内容匹配的记录?或者您是否想显示可点击的页码以在这些页面的结果之间来回切换?更多细节请...
-
当用户输入 positionid 并点击搜索时,必须显示与搜索结果匹配的结果......带有可点击的页码来回......抱歉不清楚...... .
标签: javascript coldfusion