这是我更新的代码。
<cfquery datasource="#dsn#" name="list">
SELECT film_Director
FROM main_Films
WHERE film_Active = '1'
GROUP BY film_Director
</cfquery>
<cfset OnEachPage=15>
<cfparam name="StartRow" default="1">
<cfset EndRow=StartRow + OnEachPage - 1>
<cfif EndRow GTE list.RecordCount>
<cfset EndRow=list.RecordCount>
<cfset Next=false>
<cfelse>
<cfset Next=true>
<cfif EndRow + OnEachPage GT list.RecordCount>
<cfset NextNum=list.RecordCount - EndRow>
<cfelse>
<cfset NextNum= OnEachPage>
</cfif>
<cfset NextStart=EndRow + 1>
</cfif>
<cfif StartRow IS 1>
<cfset Previous=false>
<cfelse>
<cfset Previous=true>
<cfset PreviousStart=StartRow - OnEachPage>
</cfif>
<cfset NumPages=Ceiling(list.RecordCount / OnEachPage)>
<cfparam name="PageNum" default="1">
<cfoutput><br>
<center>Display Page #StartRow# to #EndRow# dari #list.RecordCount# Search.</center><p>
</cfoutput>
<table border="0">
<tr align="center">
<td valign="top">
<cfif Previous>
<cfoutput>
<a href="filmby_Director.cfm?StartRow=#PreviousStart#& PageNum=#DecrementValue(PageNum)#<cfif IsDefined("Keyword")>&Keyword=#URLEncodedFormat(Keyword)#</cfif>"><< Page Before</a>
</cfoutput>
<cfelse>
</cfif>
</td>
<cfloop from="1" to="#NumPages#" index="ThisPage">
<cfoutput>
<cfif ThisPage IS PageNum>
<td>#ThisPage#</td>
<cfelse>
<cfset PageNumStart=(((ThisPage - 1) * OnEachPage) + 1)>
<td><a href="filmby_Director.cfm?StartRow=#PageNumStart#&PageNum=#ThisPage#<cfif IsDefined("Keyword")>&Keyword=#URLEncodedFormat(Keyword)#</cfif>">#ThisPage#</a></td>
</cfif>
</cfoutput>
</cfloop>
<td valign="top">
<cfif Next>
<cfoutput>
<i><a href="filmby_Director.cfm?StartRow=#NextStart#& PageNum=#IncrementValue(PageNum)#<cfif IsDefined("Keyword")>&Keyword=#URLEncodedFormat(Keyword)#</cfif>">Next Page >></a></i>
</cfoutput>
<cfelse>
</cfif>
</td>
</tr>
<tr>
<td valign="top" colspan="<cfoutput>#Evaluate(NumPages + 2)#</cfoutput>">
<tr><tr>
<table border="1" >
<thead>
<cfoutput>
<tr><th colspan="4">#list.film_Director#</th></th></tr>
</cfoutput>
<tr>
<th>ID</th><th>Film Name</th><th>Description</th><th>Edit Description</th>
</thead>
<cfoutput query="list" startrow="#startrow#" maxrows="#OnEachPage#">
<tbody>
<tr align="left">
<td>#director_ID#</td>
<td>#film_Name#</td>
<td>#film_Desc#</td>
<td><input type="text" name="editDesc" onBlur="this.value=this.value.toUpperCase();"></td>
</tr>
</tbody>
</tbody>
</cfoutput>
</table>
我想用电影导演分组的分页(下一页/前一页)进行查询。
数据示例:导演A / ABC电影,导演B / ASD电影,导演A / FDE电影,导演A / 123电影。
然后,我有分页页面的问题。有人能帮我吗? 如何对数据进行分组,并制作下一页。
答案 0 :(得分:0)
您使用的是哪个版本的Oracle?如果是12c,那么您可以使用新的分页功能:
select owner, object_name, object_id
from all_objects
order by owner, object_name
OFFSET 5 ROWS FETCH NEXT 5 ROWS ONLY;
答案 1 :(得分:-1)
此链接可帮助您理解
http://www.oracle.com/technetwork/issue-archive/2007/07-jan/o17asktom-093877.html
SELECT * FROM (
SELECT row_number() over (ORDER BY film_Director ASC) rownumber,
film_Director
FROM main_Films
WHERE film_Active = '1'
GROUP BY film_Director
) as q1
WHERE q1.rownumber
BETWEEN 10 AND 20
尚未经过测试,可能需要进行一些调整。