?
Solved

Navigate records

Posted on 2001-06-25
6
Medium Priority
?
319 Views
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

Searchresult.cfm

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

moredetail.cfm

 record full details

 <prev> <next>
required..

note: prev next cant be incremented or decreased by one coz primary key is not in a sequence.
cheers..
0
Comment
Question by:Yog
[X]
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
6 Comments
 
LVL 5

Author Comment

by:Yog
ID: 6223651
so what i mean is i need record navigation like ado..any tricks ..thanks so much
0
 
LVL 5

Author Comment

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

cheers
0
 
LVL 4

Accepted Solution

by:
CF_Spike earned 400 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">

<html>
<head>
     <title>Next N Interface</title>
</head>

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

<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>
<CFELSE>
<CFSET NextStart = "">
<CFSET EndRow = myQuery.RecordCount>
</CFIF>

<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>
</CFIF>
<CFELSEIF URL.StartRow GT 1>
<CFSET PrevStart = "1">
<CFELSE>
<CFSET PrevStart = "">
</CFIF>

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

</body>
</html>

Spike
0
Building an interactive eFuture classroom

Watch and learn how ATEN provided a total control system solution including seamless switching matrix switch, HDBaseT extenders, PDU, lighting control to build an interactive eFuture classroom.

 
LVL 5

Author Comment

by:Yog
ID: 6224492
Thanks so much, am working on it, brb
0
 
LVL 2

Expert Comment

by:sshhz
ID: 6226275
Yog,

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">
</form>

searchR.cfm (the search results)

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

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

<cfset OptionList = "End">

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

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

<!-- 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">
</cfif>
<cfset Prev = SearchPage - 1>
<cfset Next = SearchPage + 1>

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

<!-- Build the base link  --->
<center>
<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>
 </cfif>
</cfloop>

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

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

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

Hmm, done !!

Good Luck then.

sshhz
0
 
LVL 5

Author Comment

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

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses
Course of the Month7 days, 20 hours left to enroll

765 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