Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Structure

Participant ,
Mar 03, 2008 Mar 03, 2008
Hi all,
Maybe not the right way to do this but I am trying to put the results of a query in a structure. When I cfdump the structure it only shows one db entry not them all. Would an array be the best way to do this-or where am I going wrong? Thanks I just need to get my head clear with this concept
TOPICS
Getting started
731
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 03, 2008 Mar 03, 2008
Yes, I've also found that using #QueryName.FieldName# will only work for the first row of data. I've always had to use cfloop. Maybe something like this will work:
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Mar 03, 2008 Mar 03, 2008
I'm not sure if this is what you are trying to do, but instead of a structure, you can assign the entire result set of a query to a session variable, and that variable will contain the entire query (all rows returned).

<cfquery name="your_query" ....>
SELECT your_first_field,your_next_field
FROM your_table
</cfquery>

<cfset session.query_var = your_query>

You can then use that variable later just like you would use any other query.

<cfoutput query = "session.query_var">
#your_first_field# #your_next_field#
</cfoutput>

...etc...

Phil
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 03, 2008 Mar 03, 2008
result of a query IS a structure!
you can access any value returned by a query with an array notation:
queryname.columnname[rownumber]
or
queryname['columnname'][rownumber]

if you refer to queryname.columnname, without a rownumber, OUTSIDE of
cfoutput/cfloop, you are referencing the FIRST row only.

can you figure out how to change your code to make it work?


Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 03, 2008 Mar 03, 2008
Oh! That is very useful! I did not know that...
quote:

Originally posted by: Newsgroup User
result of a query IS a structure!
you can access any value returned by a query with an array notation:
queryname.columnname[rownumber]
or
queryname['columnname'][rownumber]

if you refer to queryname.columnname, without a rownumber, OUTSIDE of
cfoutput/cfloop, you are referencing the FIRST row only.

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 03, 2008 Mar 03, 2008
quote:

Originally posted by: Hydrowizard
Hi all,
Maybe not the right way to do this but I am trying to put the results of a query in a structure.

Why?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 04, 2008 Mar 04, 2008
I got this working before I saw Dan and Azadi´s answers(cheers) using cfloop and an array. A lot of very important concepts presented in those answers so I´m going to study them throughly. It seems that arrays are not very useful? Thanks again
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 04, 2008 Mar 04, 2008
Please help I am having same problem, thanks





Neo#1
http://www.techprodigy.net
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 04, 2008 Mar 04, 2008
quote:

Originally posted by: neo#1
Please help I am having same problem, thanks


Neo#1
http://www.techprodigy.net

What are you trying to do?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 06, 2008 Mar 06, 2008
Quote: What are you trying to do?

Answer:
Hi is trying to get some traffic to his webpage by spamming the forum!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 05, 2008 Apr 05, 2008
question answered using the cfloop and an array






Thanks
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 05, 2008 Apr 05, 2008
LATEST
My question was answered using cfloop and an array






Thanks!

Neo
www.techprodigy.net
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources