Solved

Get Query Data

Posted on 2008-10-24
10
155 Views
Last Modified: 2013-12-24
I have the following results from a query;

getstats - query - Top 3 of 3 Rows
           CNO      ID            IID         STAT_FIRST1      STAT_LEVEL1      STAT_LAST1
1       101003       1073    R1232                   W                       5                        CLINE
2       101003       1093    R7653                    J                               4                        JONES
3       101003       1152    R7812                    A                       4                        SMITH

I am learning so please bear with me.
If I need to populate a form how do I get the values. For example if I need to retrieve the  STAT_FIRST1,      STAT_LEVEL1 and  STAT_LAST1 from the second row, how would I do this without running another query?
0
Comment
Question by:usky1
  • 5
  • 5
10 Comments
 
LVL 19

Expert Comment

by:erikTsomik
Comment Utility
in order to do this you do the following
In order to get the second record just say in your query where id=1093    
<cfoutput query="getstats ">
<input type="text" name="fieldname" value="#STAT_FIRST1#"
</cfoutput>
0
 

Author Comment

by:usky1
Comment Utility
In the getstats query I need to query all the information for use later.
Is there any way that I can get the information without doing another query or query of queries?
0
 
LVL 19

Expert Comment

by:erikTsomik
Comment Utility
try is
<cfoutput query="getstats ">
<cfif getstats.recordcount  eq 2>
<input type="text" name="fieldname" value="#STAT_FIRST1#">
<cfif>
</cfoutput>
0
 

Author Comment

by:usky1
Comment Utility
The getstats.recordcount is just giving me the total number of records and displaying two values for row 1 and for row 2.
0
 
LVL 19

Accepted Solution

by:
erikTsomik earned 500 total points
Comment Utility
then try this
<cfoutput query="getstats ">

<input type="text" name="fieldname" <cfif currentrow eq 2>value="#STAT_FIRST1#"</cfif>>

</cfoutput>
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Author Comment

by:usky1
Comment Utility
The value was properly selected but it still produced two input fields, one with the correct value and one with an empty value.
 I changed the input to,
<cfif currentrow eq 2>
<input type="text" name="fieldname" <cfif currentrow eq 2>value="#STAT_FIRST1#"</cfif>>
</cfif>
And it is working now.
But is this a clean way to do what I need to?
0
 
LVL 19

Expert Comment

by:erikTsomik
Comment Utility
if you only need this you can just say in the query where id= to whatever number , IN this case you would not have to do this . However, is this always gonna look at the second row or it just a project specific

0
 

Author Comment

by:usky1
Comment Utility
Sometimes it might need to look another row.
0
 
LVL 19

Expert Comment

by:erikTsomik
Comment Utility
then this condition is fine
0
 

Author Closing Comment

by:usky1
Comment Utility
Thank you for your help.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video discusses moving either the default database or any database to a new volume.

744 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now