?
Solved

moving through an array of session variables...

Posted on 2000-03-13
6
Medium Priority
?
135 Views
Last Modified: 2013-12-24
hi.
I haven't actually put fingers to keyboard to code any CF yet, I'm still just thinking about what I'd like to do. What I'd like to know is this:

say I've got 26 names, one each A-Z, and I've got a template to pull information about each person from a db and output some html to the browser. At the bottom of the template is a 'next' and 'last' button. I guess in CF-speak that when these are clicked you are effectively reloading the page and  replacing one session variable (ie the name of the record currently being pulled) with a new one (next or last, as the case may be). But how does the page know what the 'next' or 'last' session variable is? Are they held in some kind of array, and for 'next' the next record of the array is read and for 'last' the previous array entry? Or is it just the next record (ie, row) in the table that is being read from?

Like I say I'm just thinking out loud (it's a slow day in the office and I've got some points to burn...). By all means tell me to RTFM, but then you don't get the points...;-)

thanks,

Cath
0
Comment
Question by:cath
[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
6 Comments
 
LVL 1

Expert Comment

by:bigbadb
ID: 2612591
well you would pull the total number of records from the datasource

<cfquery name="test" datasource="">
select * from table

then you would load a sessionvar to be set to test.recordcount.  THis would give the total records.

the next would be a count bascially the would increment where you were + 1 and the last would be test.recordcount


On the main page you would loop through the query until you found the recordnumber you were looking for


If you want code let me know but since you are just thinking I thought this would suffice
0
 

Author Comment

by:cath
ID: 2612626
oh no, I _will_ want code, I just haven't gotten around to putting it all together yet...;-)

I need to get my new machine, then get CFStudio, then set up CF Server, then I can start playing around with code... but if you'd like to give it, I'd sure like to have it...

also, any pointers to good CF tutorials that deal with this sort of thing (already have the Webmonkey CF tutorial), that would be great too.

thanks in advance.

Cath
0
 
LVL 5

Expert Comment

by:nathans
ID: 2613441
Check out the ColdFusion Tips Plus e-ZINE at
http://www.nsnd.com/cftips

subscribe by sending an blank email to
subscribe-cftips@nsnd.com


I am the creator of this resource which will allow you to find code and websites to help you.
0
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.

 
LVL 1

Accepted Solution

by:
rod_nolan earned 400 total points
ID: 2614691
Hi Cath,

Here's some code that does what bigbadb was talking about, generally. It doesn't use session variables but I think it results in the same interface as what you described.

The code is specific to my query, but it's commented so you should be able to modify it to fit your needs.

Good Luck,
Rod


<!--- set the maximum number of rows to display --->
<cfset MaxRows = 1>
<!--- and set the default record to start at (if this is the first time) --->
<cfparam name="START" default="1">

<!--- Do the query to get the required details --->
<cfquery name="getContact" datasource="rodweb">
      SELECT *
      FROM Contacts
      <cfif isDefined("Form.ContactID")>
      WHERE ContactID = #Form.ContactID#
      </cfif>
      ORDER BY LastName
</cfquery>

<!--- output the query results --->
<cfoutput query="getContact" startrow=#start# maxrows=#MaxRows#>
      <b>#getContact.FIRSTNAME# #getContact.LASTNAME#</b><br>
      <a href="mailto:#getContact.EMAIL#">#getContact.EMAIL#</a><br>
      #getContact.HomePhone#<br>
      #getContact.WorkPhone#<br>
      #getContact.CellPhone#<br>
</cfoutput>

<!--- Used to determine which row to output from the query on the next request --->
<cfset PrevStart = Start - MaxRows>
<cfset NextStart = Start + MaxRows>

<!--- only show the next or previous buttons if there are next or previous records --->
<table><tr><td>
            <form action="same_page_as_this_one.cfm" method="post">
                  <input type="hidden" name="start" value="<cfoutput>#PrevStart#</cfoutput>">
                  <input type="image" src="prev.gif">
            </form>
</td><td>
            <form action="ContactDetails.cfm" method="post">
                  <input type="hidden" name="start" value="<cfoutput>#NextStart#</cfoutput>">
                  <input type="image" src="next.gif">
            </form>
</td></tr></table>

0
 

Author Comment

by:cath
ID: 2620067
many thanks for that - I look forward to playing about with the code in a few weeks when I get my new machine and get CF Studio up there.

Cath
0
 
LVL 1

Expert Comment

by:rod_nolan
ID: 2621606
I guess it would only be right, at this point, to disclose my source for the above code :)

The ColdFusion Web Application Construction Kit, Third Edition
Ben Forta (ISBN 0-7897-1809-x)  
p. 498 - 503

These books (the other one is called Advanced ColdFusion Application Development, ISBN 0-7897-1810-3) are essential reading if you're interested in becoming a serious ColdFusion programmer.

Good Luck,
Rod
0

Featured Post

How Blockchain Is Impacting Every Industry

Blockchain expert Alex Tapscott talks to Acronis VP Frank Jablonski about this revolutionary technology and how it's making inroads into other industries and facets of everyday life.

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…
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 …
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

743 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