我在ColdFusion頁面上有下面的代碼。此頁面顯示下面的查詢中的數據,每頁有25條記錄並附有分頁。現在我需要提供一個文本框和搜索按鈕,以便用戶可以輸入positionid並點擊搜索....我在這裏遇到的問題是,如果positionid在例如第7頁出現時如何顯示第n頁200頁。請指教。謝謝Coldfusion分頁和搜索
<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並點擊搜索結果必須顯示匹配的搜索結果....與可點擊的頁碼來回去......抱歉不清楚.... – user747291