Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cfsavecontent question

Status
Not open for further replies.

countdrak

Programmer
Jun 20, 2003
358
US
I have a query which I use to generate a html page. So,

<cfquery datasource = "mydsn" name = "myquery">
SELECT ...
...

</cfquery>

Then I do
<cfoutput query = "myquery>
<tr>
<td class="Border">#myquery.ID#</td>
<td class="Border">#myquery.Column1#</td>
<td class="Border">#myquery.Column2#</td>
<td class="Border">#myquery.Column3#</td>
<td class="Border">#myquery.Column4#</td>

</tr>
</cfoutput>

Now I want to use <cfsavecontent> so instead of generating an output I can store it in a variable and then use cffile to write it to a file. How do I do that? I dont think I can do

<cfloop query = "myquery">
<cfsavecontent>...
 
There are two methods.

And yes, you can do what you said you didn't think you could.

There's

Code:
<cfsavecontent variable="holdcontent"><cfoutput query  = "myquery>
    <tr>
      <td class="Border">#myquery.ID#</td>
      <td class="Border">#myquery.Column1#</td>
      <td class="Border">#myquery.Column2#</td>
      <td class="Border">#myquery.Column3#</td>
       <td class="Border">#myquery.Column4#</td>
     
  </tr>
</cfoutput></cfsavecontent>

...and...

Code:
<cfset arrHold=ArrayNew(1)>
<cfoutput query  = "myquery>
    <cfsavecontent variable="tempHold"><tr>
      <td class="Border">#myquery.ID#</td>
      <td class="Border">#myquery.Column1#</td>
      <td class="Border">#myquery.Column2#</td>
      <td class="Border">#myquery.Column3#</td>
       <td class="Border">#myquery.Column4#</td>
  </tr></cfsavecontent>
  <cfset arrHold[currentrow] = tempHold>
</cfoutput>

The first example loads the entire output into one variable.

The second example loads each record's output into its own array element so that you can access them seperately later.

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top