Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
brokerandy25 #1
repeating records when using cfoutput
For some reason this code being looped through and outputting 4 records then 3
records then 2 records then 1 record. any ideas why? and how to fix it?
<cfoutput query="Recordset1">
<table cellpadding="2" cellspacing="0" border="0">
<cfset col = 1><tr>
<cfoutput>
<td><img src="#Recordset1.PictureURL#" alt="#Recordset1.PictureURL#"
width="#Recordset1.width#"
height="#Recordset1.height#"><br>#Recordset1.capti on#</td>
<cfif col IS 2></tr><cfset col = 1><cfelse><cfset col = 2></cfif>
</cfoutput>
<cfif col IS 2><td> </td></tr></cfif>
</table>
</cfoutput>
brokerandy25 Guest
-
Cfoutput help!!!
I am trying to figure out how to output records from a query that is returing 2 distinct table rows from each query. THe out put needs to look like... -
cfoutput and css
I declare an entire document within a <cfoutput> </cfoutput> section. I am trying to insert the following css style descriptor into the code: ... -
cfoutput prblem
Hi: I made a registration page with coldfusion, then I want the user to edit it's info. So I started the page with a cfquesry and then a cfoutput ... -
Organizing CFoutput?
I am working with a MySQL database that I am pulling information about shops from all over the world and country. I am pulling the information... -
<cfoutput>
Hi. I'm trying to rename a file but I get an error message. My code looks someting like this: <cfset source='C:\MyDocs\old.doc'> <cfset... -
mxstu #2
Re: repeating records when using cfoutput
What do you mean by "Fix it"? What do you want it to do? Also, you have a cfoutput nested within your cfoutput "query". It doesn't look like it is necessary for the code you have posted.
mxstu Guest
-
brokerandy25 #3
Re: repeating records when using cfoutput
sorry little vague, I am well aware of the nesting of the output tags. I am
trying to query a data base and pull out all relevant picture <img src>'s and
captions and output like this
1 2
1.c 2.c
3 4
3.c 4.c
I am having the hardest time with this.
And I do appreciate the help
andy
brokerandy25 Guest
-
Bill #4
Re: repeating records when using cfoutput
Try
SELECT DISTINCT
in your query
--
Bill
Marketweaver Module For Cartweaver
[url]http://www.datapacks.com[/url]
New Support Newsgroup: [url]http://www.datapacks.com/home.cfm?ThisPage=support[/url]
Blog: [url]http://www.datapacks.com/Blog/[/url]
Cartweaver Add-ons & Custom Cartweaver Modifications
Skype Username: DataPacks.com
"brokerandy25" <webforumsuser@macromedia.com> wrote in message
news:darron$7je$1@forums.macromedia.com...> sorry little vague, I am well aware of the nesting of the output tags. I
> am
> trying to query a data base and pull out all relevant picture <img src>'s
> and
> captions and output like this
> 1 2
> 1.c 2.c
> 3 4
> 3.c 4.c
>
> I am having the hardest time with this.
>
> And I do appreciate the help
>
> andy
>
Bill Guest
-
brokerandy25 #5
Re: repeating records when using cfoutput
Bill I appreciate the effort, but unfortunately that did not help, could it be
that this is an Access DB that is causing problems, or do you have some code
that would work better for what I am trying to do?
brokerandy25 Guest
-
MikerRoo #6
Re: repeating records when using cfoutput
The posted code, while not optimal, is not the source of the stated problem.
The problem must be in the query or some other section of code.
Also when posting code, please use the "Attach Code" button.
Thanks,
-- MikeR
MikerRoo Guest
-
dempster #7
Re: repeating records when using cfoutput
I think the problem is in your code. You are using one CFOUTPUT nested inside
another. Normally this is done when you group on one of the fields -- the
second CFOUTPUT will display all individual records that are part of the group.
Your code looks like the the first (or outer) CFOUTPUT will loop through each
of the four records returned by your query. The second or inner CFOUTPUT would
then loop through all remaining records and display them. That is why you get
first 4 records, then 3, etc.
What exactly are you trying to accomplish? I thought you posted this problem
earlier with some different code.
-Paul
dempster Guest
-
MikerRoo #8
Re: repeating records when using cfoutput
I stand corrected. It IS the inner <cfoutput>.
You've set up an accidental query grouping. (And Macromedia considers this a "feature"!)
MikerRoo Guest
-
brokerandy25 #9
Re: repeating records when using cfoutput
Al right so How do I rectifiy this grouping problem? I wiped out all html (non
Relevant code) so this is it for the page. I really do appreciate everyone
taking the time to look at this.
Paul I did post this question earlier, with different code, and I was not able
to find a slution with that code, so I started again.
As for what I am trying to do, I will try to reexplain. Though I will take
the long route. My client wants to be able to up load photos to their web site
and have them automatically appear on the appropriate pages. So using cffile
we upload the file to the server, append the reletave path to the name of the
file and and input all relevant info into DB ( caption, page number for picture
to apper on, and img src '[EX: ../../Images/uploadedpictures/ ] ) Then we
query DB to pull all pictures based upon page number, (Here is where the
problem comes in) I want to pull all info from DB and out put it into a table,
2 pictures per row, with captions. Now the code I am currently using displays
records 1,2,3,4, then it repeats and displays records 3,2,1, then it repeats
and displays records 2,1 then just record 1. I have had this problem before
and it has been tied to cfoutput when outputting query results, I don't know
how I have managed to fix the problem before, I have always just deleted and
redone it.
Andy
<cfquery name="Recordset1" datasource="KidneyIndiana">
SELECT Distinct * FROM PictureTable WHERE PageToAppearON =
'#URL.PageToAppearON#'
ORDER BY AutoNumber DESC
</cfquery>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>NKF - Summer Camp</title>
brokerandy25 Guest
-
MikerRoo #10
Re: repeating records when using cfoutput
Okay, Replace the output section with the attached.
It will display two pictures per row.
-- MikeR
<div id="Layer2" style="position:absolute; left:21px; top:168px; width:768px;
height:94px; z-index:1; visibility: visible;"
onMouseOver="MM_showHideLayers('sub5','','hide','s ub4','','hide','sub3','','hide
','sub2','','hide','menu1','','hide')">
<!--- **** This font tag is not always closed. **** ---><font
color="#993399" size="+2" face="Arial, Helvetica, sans-serif">
<CFIF recordset1.recordcount EQ 0>
</font>
<div align="center"><font color="#993399" size="+2" face="Arial,
Helvetica, sans-serif">We
are sorry, but we have not uploaded any pictures for this event.<br>
Please check back often.</font> </div>
<CFELSE>
<CFSET iPicsPerRow = 2>
<table cellpadding="2" cellspacing="0" border="0">
<tr>
<CFOUTPUT query="Recordset1">
<td>
<img src="#Recordset1.PictureURL#" alt="#Recordset1.PictureURL#"
width="#Recordset1.width#" height="#Recordset1.height#">
<br>#Recordset1.caption#
</td>
<CFIF 0 EQ (CurrentRow MOD iPicsPerRow)> </tr><tr> </CFIF>
</CFOUTPUT>
</tr>
</table>
</CFIF>
</div>
</body>
</html>
MikerRoo Guest
-
brokerandy25 #11
Re: repeating records when using cfoutput
MikeRoo - thank you very much. I really appreciate the time, and if you would
like to take the time, could you explain the code. I know that sounds stupid,
but I cann't find any documentaion on the MOD.
Thank you,
Andy
brokerandy25 Guest
-
MikerRoo #12
Re: repeating records when using cfoutput
Mod is a fairly common operator in many programming languages.
The CF version is documented
[url]http://livedocs.macromedia.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/[/url]
wwhelp.htm?context=ColdFusion_Documentation&file=0 0000926.htm.
CurrentRow MOD XXX will only be zero on every XXX'th row in the recordset.
In this case, that is when we want to start a new table row.
MikerRoo Guest
-
MikerRoo #13
Re: repeating records when using cfoutput
Also, I should have used "Recordset1.CurrentRow" in the code to be a little clearer and to make the code more robust.
MikerRoo Guest
-



Reply With Quote

