Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


ColdFusion: need to loop through query and set session vars for output

Posted on 2011-10-05
Medium Priority
Last Modified: 2012-06-21
currently capturing session vars for Application Admin user roles this way:
<CFIF #qry_findAppAdmin.recordCount# GT 0>
      <cfset session.AppAdminFName = #qry_findAppAdmin.first_name#>
      <cfset session.AppAdminLName = #qry_findAppAdmin.last_name#>
      <cfset session.AppAdminEmail = #qry_findAppAdmin.email_address#>
      <cfset session.AppAdminPhone = #qry_findAppAdmin.user_phone#>
      <cfset session.AppAdminFName = ''>
      <cfset session.AppAdminLName = ''>
      <cfset session.AppAdminEmail = ''>
      <cfset session.AppAdminPhone = ''>

Now must handle multiple Application Admin users, not just one. Am hung up on how to code an array or such to create multiple session variables. Immediate goal: need to send multiple emails (i..e. cfmail ) to multiple Application Administrators.

Thanks very much
Question by:mchristopher
  • 3
  • 2
LVL 39

Expert Comment

ID: 36916871

The primary use of session variables is to maintain a login and other session-specific information.   It sounds like you should not use session variables for the purpose you've described.  The email addresses do not all belong to the person logged in, so don't asscociate them with his session.

To do what you want, simpley query the admin and loop through them using CFMAIL to email each one..

Author Comment

ID: 36918235
Understood. Just following (somewhat blindly) the template at hand.
Will try the loop and let you know.
LVL 39

Accepted Solution

gdemaria earned 1500 total points
ID: 37136041
Did that work?

Author Closing Comment

ID: 37152427
I already solved the issue by looping through the query and converting the results into an array. I found the code to do this on Google, not through the answer posted. The answer told me what to do not how to do it.
Partial credit is my recommendation. Thanks.
LVL 39

Expert Comment

ID: 37153577
That's no problem.

For future reference however, if you are going to grade below an "A" grade you need to ask for additional information first.   Your last post was that you would give it a try and let me know.  

Regarding the question, I don't know the specifics of your code (perhaps there is some unusual circumstance) but from what you posted, I stand by the answer... there's no need for you to create session variables or an array.  If you're just pulling the admins from the database, then simply loop through your query and send them each an email...

If you feel you need to do session variables or arrays or something, then the question does not supply enough information to justify it these extra steps.


Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

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

This article  is about submitting  form through  ColdFusion.Ajax.submitForm to the action page and send a response back in JSON format which later can be decoded using ColdFusion.JSON.decode. By this way you can avoid the usual page refresh for subm…
Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
Integration Management Part 2
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

581 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