Solved

Get Query Data

Posted on 2008-10-24
10
162 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
ID: 22798876
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
ID: 22798940
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
ID: 22798982
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
ID: 22799050
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
ID: 22799680
then try this
<cfoutput query="getstats ">

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

</cfoutput>
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:usky1
ID: 22799923
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
ID: 22800055
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
ID: 22800767
Sometimes it might need to look another row.
0
 
LVL 19

Expert Comment

by:erikTsomik
ID: 22801433
then this condition is fine
0
 

Author Closing Comment

by:usky1
ID: 31509759
Thank you for your help.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Concerto provides fully managed cloud services and the expertise to provide an easy and reliable route to the cloud. Our best-in-class solutions help you address the toughest IT challenges, find new efficiencies and deliver the best application expe…
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

932 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

13 Experts available now in Live!

Get 1:1 Help Now