Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Page Results in a nested Group Query

Status
Not open for further replies.

neofactor

Technical User
Jul 30, 2000
194
US
My question is how do you page through records if you have them nested in a Group Sort.

Example:
--------------------------------------------------
<cfoutput query=&quot;SEARCH&quot; group=&quot;LocationName&quot; startrow=&quot;#start#&quot; maxrows=&quot;#display#&quot;>

#LocationNAME#

<cfoutput>
#SEARCH.CurrentRow# #LASTNAME#, #FIRSTNAME#
</cfoutput>

</CFOUTPUT>
--------------------------------------------------

If I enter in ther Max row in the initial <CFOUTPUT> I do not get the desired result. Is it at all possible?

Please advise me with any help.

Thank you,
David :)
 
Hey David,

There are a couple of different ways you can do this but with your existing code, I would just add a <cfif> statement. This isn't the most efficient way but if your site isn't under a heavy load and your record set doesn't have a lot of records, it shouldn't be a problem.

<cfoutput>
<cfif search.currentRow lt (start + display)>
#SEARCH.CurrentRow# #LASTNAME#, #FIRSTNAME#
</cfif>
</cfoutput>

I haven't tested this so let me know if you have any trouble,
GJ
 
THis code will place your records in multiple pages and have next and previous butttons in the pages. you can select how many records you can keep in a page from a combo box.

please change all the values which have to be changes, like , form name, file name in ahref, query name etc.

i hope it help you

CFFORM name=&quot;form&quot; method=&quot;post&quot;>


<cfparam name=&quot;start&quot; default=&quot;1&quot;>
<cfparam name=&quot;display&quot; default=&quot;2&quot;>
<cfif IsDefined(&quot;url.disp&quot;) is &quot;True&quot;>
<cfset display = #url.disp#>
</cfif>

<cfset ColumnCount=8>
<input type=&quot;hidden&quot; name=&quot;TestAction&quot;>
<input type=&quot;text&quot; name=&quot;record&quot; >


<CFQUERY
DATASOURCE=&quot;xxx&quot;

NAME=&quot;xxx&quot; cachedwithin=&quot;#CreateTimeSpan(0,0,10,0)#&quot;>
select * from xxx order by xxx
</CFQUERY>

<cfset nextX = #start# + #display#>
<!---Calculate the &quot;previous&quot; value--->
<cfset PrevX = #start# - #display#>

<cfif PrevX LTE 0><cfset PrevX = 1></cfif>



<CFOUTPUT
QUERY =&quot;xxx&quot; startrow=&quot;#start#&quot; maxrows=&quot;#display#&quot;>

<cfif (queryname.CurrentRow GT start) AND ((getunittypeslist.CurrentRow mod ColumnCount) is 1)>

</cfif>
<tr valign=&quot;top&quot; class=&quot;xxx&quot;>
<td>#put your data base filed here #</td>
<td>#put your data base filed here #</td> </tr>
</CFOUTPUT>


<td>

Choose number of records you want to display in this page :
<select name= &quot;records&quot; onChange=&quot;board(this.selectedIndex)&quot; selected=&quot;document.form.records[index].value&quot;>
<option value=&quot;2&quot;>2</option>
<option value=&quot;4&quot;>4</option>
<option value=&quot;6&quot;>6</option>



</select>
<script language=&quot;javascript&quot;>
function board(index){

var temp1;

temp1 = document.orm.records[index].value;
document.form.action=&quot;List1.cfm?disp=&quot; +temp1;
document.form.submit();
}
</script>
</td>
</tr>
<cfif #start# is not 1>
<cfoutput>
<a href=&quot;List1.cfm?start=#PrevX#&display=#display#&quot;>
previous
</a>
</cfoutput>
</cfif>


<!---Next (X) (only show this link if there are more results available)--->
<cfif nextX LTE getunittypeslist.RecordCount>
<cfoutput>
<a href=&quot;List1.cfm?start=#nextX#&display=#display#&quot;>
next
</a>
</cfoutput>
</cfif>
</td>
</tr>

</table>

</CFFORM>


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top