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!

displaying the output of CFQUERY or CFSEARCH by pages

Status
Not open for further replies.

djy

Programmer
Jul 13, 2000
6
US
This seems like it should be easy, but as a new (and as of yet untrained) CF developer, I just seem to be banging my head against the wall.<br><br>I have created a Verity collection for use in a site search.&nbsp;&nbsp;When users do a keyword search, I would like to display the matches 10 per page with &quot;heading&quot; information such as &quot;82 matches for xyz -- Displaying records 11-20.&quot;<br><br>Is there a way to do the query once (to get the appropriate RecordCount value) and then display x number of matches per page?&nbsp;&nbsp;I see several commands that include startrow and maxrow parameters, but nothing to indicate how I move from the display of the first x records to the next x records.<br><br>TIA for any help.
 
Here's something I'm working on at the moment, which might help... It collects news items from a database... Initially it displays the ten most recent items, but the links at the bottom of the page enable the user to display more if they want....<br><br>&lt;cfparam name=&quot;url.items&quot; default=&quot;10&quot;&gt;<br><br>[... you might need to do another query here to get your RecordCount... Or perhaps RecordCount is unaffected by startrow and maxrow parameters? Try it! Let me know...]<br><br>&lt;cfquery name=&quot;get_items&quot; datasource=&quot;Local News&quot; maxrows=&quot;#url.items#&quot;&gt;<br><br>[... In your case, you'd need to supply startrow as a url variable, initially set to 1, I presume...]<br><br>SELECT ID, Date, Headline<br>FROM News<br>WHERE 1=1<br>ORDER BY Date DESC<br>&lt;/cfquery&gt;<br><br><br>&lt;table&gt;<br>&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt;&lt;h1&gt;&lt;b&gt;Local News&lt;/b&gt;&lt;/h1&gt;&lt;/td&gt;&lt;/tr&gt;<br>&lt;cfset rowflag=1&gt;<br>&lt;cfoutput query=&quot;get_items&quot;&gt;<br><br>&lt;tr&gt;&lt;td&gt;#Date#&lt;/td&gt;&lt;td&gt;#Headline#&lt;/td&gt;&lt;/tr&gt;<br>&lt;/cfoutput&gt;<br>&lt;/table&gt;<br>&lt;p&gt;<br><br>View [&lt;a href=&quot;local.cfm?items=10&quot;&gt;10&lt;/a&gt;] [&lt;a href=&quot;local.cfm?items=20&quot;&gt;20&lt;/a&gt;] [&lt;a href=&quot;local.cfm?items=30&quot;&gt;30&lt;/a&gt;] [&lt;a href=&quot;local.cfm?items=40&quot;&gt;40&lt;/a&gt;] [&lt;a href=&quot;local.cfm?items=999&quot;&gt;all&lt;/a&gt;] items<br><br>[...You'd need to set up another url variable in these links, to provide a value for your startrow parameter... e.g. ?items=10&startitem=1, ?items=20&startitem=11, ?items=30&startitem=21...]<br><br>Does this help?<br><br>Tam.<br>
 
maxrows definitely affects the RecordCount value so a 2nd query is probably necessary.&nbsp;&nbsp;Will give this a try and let you know how it comes out.
 
turns out it wasn't Cold Fusion that was the culprit...it was the JScript that was setting the new pointer value based on whether the user picked Next or Prev from the display.&nbsp;&nbsp;I still have to tweak the CF part a bit, but I think the basics are now working as originally expected.&nbsp;&nbsp;Thanks again for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top