<!--- This example shows the use of CFQUERY --->
<HTML>
<HEAD>
	<TITLE>CFQUERY Example</TITLE>
</HEAD>

<BODY  bgcolor="#FFFFD4">

<H3>CFQUERY Example</H3>

<!--- define startrow and maxrows to facilitate
'next N' style browsing --->
<CFPARAM name="MaxRows" default="10">
<CFPARAM name="StartRow" default="1">

<!--- query database for information --->
<CFQUERY NAME="GetParks" DATASOURCE="cfsnippets">
SELECT      PARKNAME, REGION, STATE
FROM         Parks 
ORDER by ParkName, State
</CFQUERY>

<!--- build HTML table to display query --->
<TABLE cellpadding=1 cellspacing=1>
<TR>
	<TD colspan=2 bgcolor=f0f0f0>
	<B><I>Park Name</I></B>
	</TD>
	<TD bgcolor=f0f0f0>
	<B><I>Region</I></B>
	</TD>
	<TD bgcolor=f0f0f0>
	<B><I>State</I></B>
	</TD>
</TR>

<!--- Output the query and define the startrow and maxrows
	  parameters. Use the query variable CurrentCount to
	  keep track of the row you are displaying. --->
<CFOUTPUT query="GetParks" StartRow="#StartRow#" MAXROWS="#MaxRows#">
<TR>
	<TD valign=top bgcolor=ffffed>
	<B>#GetParks.CurrentRow#</B>
	</TD>
	<TD valign=top>
	<FONT SIZE="-1">#ParkName#</FONT>
	</TD>
	<TD valign=top>
	<FONT SIZE="-1">#Region#</FONT>
	</TD>
	<TD valign=top>
	<FONT SIZE="-1">#State#</FONT>
	</TD>
</TR>
</CFOUTPUT>

<!--- If the total number of records is less than or equal
to the total number of rows, then offer a link to
the same page, with the startrow value incremented by
maxrows (in the case of this example, incremented by 10) --->
<TR>
	<TD colspan=4>
	<CFIF (StartRow + MaxRows) LTE GetParks.RecordCount>
		<a href="cfquery.cfm?startrow=<CFOUTPUT>#Evaluate(StartRow + MaxRows)#</CFOUTPUT>">See next <CFOUTPUT>#MaxRows#</CFOUTPUT> rows</A>
	</CFIF>
	
	</TD>
</TR>
</TABLE>
</BODY>
</HTML>