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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search Engine Help (previous 1 2 3 4 5 6 7 next) 1

Status
Not open for further replies.

lathodio

Programmer
Mar 25, 2000
9
SI
I am building a search engine and am trying to figure out how to build a navagation bar at the bottom of the page that takes you to the next page of search results

EXAMPLE

previous 1 2 3 4 5 6 7 8 9 10 next

I am new to cold fusion and would appreciate some help in terms that I can understand

Thanks
 
Hi, lathodio! I have done this, so hopefully I can help. (I'm new to CF,too,BTW)

First, you need to set up some counter variables and variables to keep track of which page you are on.
Code:
!--- "FirstRow" designate the first row on a page." --->
<cfparam name=&quot;FirstRow&quot; default=&quot;1&quot;>
<!--- &quot;Counter&quot; keeps track of which page we are on --->
<cfparam name=&quot;Counter&quot; default=&quot;1&quot;>
<!--- If &quot;FirstRow&quot; and &quot;Counter were passed from the previous page, use them.&quot; --->
<cfif IsDefined (&quot;URL.First&quot;)>
	<cfset FirstRow = URL.First>
</cfif>
<cfif IsDefined(&quot;URL.Counter&quot;)>
	<cfset Counter = URL.Counter>
</cfif>
<!--- These are for the navigation bar. --->
<cfset StartNextPage = FirstRow + 1>
<cfset StartLastPage = FirstRow - 1>

Here is my navigation bar.
Code:
<!--- Navigation bar --->
<cfoutput>
<DIV ALIGN=&quot;center&quot;>
<table>
<tr>
    <TH>
	<cfif StartLastPage GTE 1>
		<a href=&quot;SearchDisplayMessage.cfm?First=#StartLastPage#&ResultsList=#URL.ResultsList#&quot;><SPAN CLASS=&quot;BigBlack&quot;>Previous Message</SPAN></a>
	</cfif>   
	</TH>
    <TH>
	<cfif StartNextPage LTE GetMessages.RecordCount>
		<a href=&quot;SearchDisplayMessage.cfm?First=#StartNextPage#&ResultsList=#URL.ResultsList#&quot;><SPAN CLASS=&quot;BigBlack&quot;>Next Message</SPAN></a>
	</cfif>
	</TH>
	<TH>
		<SPAN CLASS=&quot;BigBlack&quot;>Message #First# of #GetMessages.RecordCount#</SPAN>
	</TH>
</TR>
</TABLE>
</DIV>
</CFOUTPUT>
<!--- Output message --->
<cfoutput query=&quot;GetMessages&quot;
          startrow=#FirstRow#
          maxrows=1>
		  <CFINCLUDE TEMPLATE=&quot;Highlighter.cfm&quot;>
<!--- SearchMessage.cfm is just a form to display the message. --->
		  <CFINCLUDE TEMPLATE=&quot;SearchMessage.cfm&quot;>
</CFOUTPUT>

Code:
<!--- Increment counters. --->
<!--- I am incrementing FirstRow by 1 because I am displaying one result per page. Make this however many results you want to display on one page. -->
<cfset FirstRow = FirstRow + 1>
<cfset Counter = Counter + 1>

I didn't do the display on the bottom showing all the pages like you seem to be asking, but as you can see from my navigation bar, I do show &quot;Previous&quot;,&quot;Next&quot;(if applicable), and I show which record out of how many you are looking at. Hopefully, this will get you started. Let me know how it goes. Good luck!

Calista :)
 
One other thing, when you're outputing your query results, set MAXROWS to however many results you want on one page.

Calista
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top