Navigate records

Posted on 2001-06-25
Last Modified: 2013-12-24
Primary key is not in a order in search result. Need to navigate the records. Anyone have any ideas..

Display should be


 recordone hyperlink to moredetail.cfm
 recordtwo hyperlink to moredetail.cfm
 recordlast hyperlink to moredetail.cfm


 record full details

 <prev> <next>

note: prev next cant be incremented or decreased by one coz primary key is not in a sequence.
Question by:Yog
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4

Author Comment

ID: 6223651
so what i mean is i need record navigation like ado..any tricks ..thanks so much

Author Comment

ID: 6223749 i incremented the start and end rows accordingly..silly me!, any other ideas welcome ..


Accepted Solution

CF_Spike earned 100 total points
ID: 6224117
Depending on what type of data you are querying you could use array syntax to access the numeric index for the query. This is fine for data which is unlikely to change while the user is browsing through the results. If it is likely that the data will change during that time you could put the query in a shared scope such as the server scope or the session scope if the query relates only to 1 particular user. If the query returns a large amount of data this would not be desirable as the query would be using up memory on the ColdFusion Server. In that case you would almost certainly be better off using a StoredProcedure to return only the records you want for each request.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

     <title>Next N Interface</title>

<CFSET myQuery = QueryNew('ColumnName')>
<CFLOOP FROM="1" TO="200" INDEX="i">
<CFSET NULL = QueryAddRow(myQuery)>
<CFSET NULL = QuerySetCell(myQuery,'ColumnName','Row#i#')>

<CFPARAM Name="url.StartRow" Default="1">
<CFPARAM Name="url.count" Default="10">

<CFIF (url.StartRow + url.Count) LTE myQuery.RecordCount>
<CFSET NextStart = url.StartRow + url.count>
<CFSET EndRow = NextStart>
<CFSET NextStart = "">
<CFSET EndRow = myQuery.RecordCount>

<CFIF (url.StartRow - url.Count) GTE 1>
  <CFSET PrevStart = url.StartRow - url.Count>
  <CFSET CheckStart = PrevStart + (url.count -(PrevStart-1) mod url.count)>
<CFIF CheckStart NEQ URL.StartRow>
  <CFSET PrevStart = CheckStart>
<CFSET PrevStart = "1">
<CFSET PrevStart = "">

<CFLOOP FROM="#url.StartRow#" TO="#Variables.EndRow#" index="i">
<TD STYLE="color:silver">
<CFIF Len(Variables.prevStart)>
<A HREF="#cgi.script_name#?StartRow=#prevStart#&count=#url.count#">Prev</A>
<TD STYLE="color:silver">
<CFIF Len(Variables.NextStart)>
<A HREF="#cgi.script_name#?startRow=#NextStart#&Count=#url.Count#">Next</A>


Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.


Author Comment

ID: 6224492
Thanks so much, am working on it, brb

Expert Comment

ID: 6226275

I ve something like that. It's a bit long, but you can modify to make it suits your shoe. :)

A search form will be as the interface, as the result of submitting the button SEARCH, then my search result will be display in another page.

search.cfm (interface form to search)

<form action="SearchR.cfm" method="post">
username: <INPUT TYPE="text" NAME="Username" Size="20">
<INPUT TYPE="Submit" Name="Search" Value="Search">
<input type="hidden" name="FormSearch" value="Yes">

searchR.cfm (the search results)

<cfif IsDefined("Form.FormSearch")>
 <cfif IsDefined("Form.SearchPage")>
   <cfset SearchPage = "Form.SearchPage">
   <cfset SearchPage = "1">
 <!-- your search criterias must defined here -->    
 <cfif #Form.Username# is not "">
   <cfset SearchUsername = Form.Username>
   <cfset SearchUsername = "All Users">  

 <cfif IsDefined("URL.SearchPage")>
   <cfset SearchPage = URL.SearchPage>
   <cfset SearchPage = "1">
 <cfif IsDefined("URL.Username")>
   <cfset SearchUsername = URL.Username>
   No Username is defined!

<cfset OptionList = "End">

<cfquery datasource='myDNS' name="getMember">
  Select * From Member
  <cfif #trim(SearchUsername)# is "All Users">
    Where Username  LIKE '%'
    Where Username LIKE '#SearchUsername#%'

  <cfloop index="QueryItem" list="#OptionList#">
     <cfif QueryItem is Not "End">
     and #QueryItem# = 1

<!-- Set the constants --->
<cfset ResultsPerPage = "30">
<cfset PageStart = "1">

<!--- Setup the variables --->
<cfset NumOfPages = Ceiling(getMember.RecordCount / ResultsPerPage)>
<cfset FirstResult=ResultsPerPage * SearchPage - (ResultsPerPage - 1)>
<cfset LastResult=ResultsPerPage * SearchPage>
<cfif LastResult GTE getMember.RecordCount>
     <cfset LastResult=getMember.RecordCount>
     <cfset LastPage="yes">
<cfset Prev = SearchPage - 1>
<cfset Next = SearchPage + 1>

<cfloop query="getMember" startrow="#FirstResult#" endrow="#LastResult#">
 #FullName# #DOB# #Address#

<!-- Build the base link  --->
<cfset baselink = "SearchR.cfm?Username=#URLEncodedFormat(SearchUsername)#">

<cfloop index="QueryItem" list="#OptionList#">
 <cfif QueryItem is Not "End">
   <cfset addon = "&#QueryItem#=Yes">
   <cfset baselink = baselink & addon>

<!--- Set the "Previous" link, if any --->
<cfif Prev GTE 1>
  <cfset addon = "&SearchPage=#URLEncodedFormat(Prev)#">
  <cfset PreviousLink = baselink & addon>
    [<a href="#PreviousLink#">&lt;&lt;Previous</a>

<!--- Set all the page numbers --->
<cfloop index="PageCount" from="1" to="#NumOfPages#">
  <cfset addon = "&SearchPage=#URLEncodedFormat(PageCount)#">
  <cfset PageLink = baselink & addon>
  <cfif SearchPage is PageCount>
    <A href="#PageLink#">#PageCount#</A>
<!--- Set the "Next" link, if any --->
<cfif IsDefined("LastPage") is False>
  <cfset addon = "&SearchPage=#URLEncodedFormat(Next)#">
  <cfset NextLink = baselink & addon>
    <A href="#NextLink#">Next&gt;&gt;</A>]
  ]<br> </P>

<cfoutput><input type="hidden" name="FormSearch" value="Yes"></cfoutput>

Hmm, done !!

Good Luck then.


Author Comment

ID: 6234792
Thanks sshh and Spike, shhzz , i have to gain some question points for you..Thanks a billion mates :)

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Interesting problem when moving between environments 6 57
Restrict IIS Website without Windows login 7 59
Problem to go to Web page 2 133
SSL Certificate for IIS7 Site 2 103
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In a recent question ( here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question