Good morning guys,

After quite a frustrating Friday afternoon into the evening, I finally got
my page to display the tables the way I needed it to. Thanks to those of you
who tried to help, it was much appreciated.

It was quite a challenge because of the double loop that had to go on. I
couldn't simply loop through each record, because the data from each record
had four separate rows, so as soon as I created the very first row, which
had two records in it, when I went to create the second row, I had to be
able to output the first record again. I was definitely going quietly insane
by the time 11:00 pm rolled around.....

Here is my final code below, and if anyone can see where I could have done
it more efficiently, I would appreciate any feedback.

Thanks again for everything, now I have to go create the side that adds the
records to begin with! <grin> ...

URL: http://www.medmeet.org/medbroadcast/programStart.cfm

CODE: (Query at top not shown)

<!-- Top table containing Heading -->
<table width="780" cellspacing="0" cellpadding="0" border="0"
align="center">
<tr>
    <td valign="top" align="left">
        <img src="images/top_banner.jpg" width=780 height=75 alt=""
border="0">
    </td>
</tr>
</table>
<table width="700" cellspacing="0" cellpadding="0" border="0"
align="center">
<tr>
        <td>&nbsp;</td>
</tr>
<tr>
    <td>
                <h2>P R O G R A M&nbsp;&nbsp;&nbsp;S T A R T</h2>
                <b><i>Program Title:</i><br>
        <h2><cfoutput>#getProgramInfo.PRTITLE#</cfoutput></h2></b>
         </td>
</tr>
<tr>
    <td><br>
    <p><b>CME certificates and Statements of Credit will be sent by mail
within 4 weeks of receipt of an evaluation form. Participants of the
audio-only portion of the program who do not successfully complete the
activity will be  notified by mail.</b>
&nbsp;</p>
    </td>
</tr>

<tr>
    <td>
<!--- Dynamic Table for program details... --->

<table width="100%" cellspacing="0" cellpadding="6" border="1">
<tr>
    <td bgcolor="#FBD5AA" colspan="2">
    <b>To receive continuing education credit, participants must listen to
the entire presentation (Parts 1 & 2), score a 70% on the posttest and
submit a complete evaluation form.</b>
    </td>
</tr>

<!--- Set up variables to keep track of columns and rows --->

<cfscript>
//This is how many columns I want
columnCount = 2;

//The counter to keep track of the rows
rowCounter = 1;

//The counters to know which record index to output
//There are 4 rows of data
subRowCounter1 = 1;
subRowCounter2 = 1;
subRowCounter3 = 1;
subRowCounter4 = 1;

//The counter for the outer loop, set equal to the amount of records.
parts = #getProgramInfo.RecordCount#;

//This is how many rows there has to be.
//I take the total amount of records, divide it by 2, and round it up. --->
rowCount = #Round(getProgramInfo.RecordCount / 2)#;

partcounter = 1;
nextrow = 0;
</cfscript>

<!--- Begin the loop --->
<cfoutput>
<cfloop from="#partcounter#" to="#rowCount#" index="myIndex">

<!--- This Row Displays Program Part Number --->
<tr>
    <!--- Need Column Counter to determine Rowspan --->
    <cfset columnCounter = 1>

    <cfloop from="#partcounter#" to="#columnCount#" index="x">
    <td bgcolor="#Request.Lightcolor#" width="50%" <cfif columnCounter EQ 1
AND rowCounter EQ #rowCount#>colspan="2"</cfif>>
        <b>PART #getProgramInfo.PPPARTNO[subRowCounter1]#<br></b>
    </td>
    <!--- Increment columnCounter --->
    <cfset columnCounter = columnCounter + 1>
    <!--- Increment subRowCounter --->
    <cfset subRowCounter1 = subRowCounter1 + 1>
    </cfloop>
</tr>

<!--- This Row Displays Program Information --->
<tr>
    <cfset columnCounter = 1>

    <cfloop from="#partcounter#" to="#columnCount#" index="x">
    <td <cfif columnCounter EQ 1 AND rowCounter EQ
#rowCount#>colspan="2"</cfif>>
    <b>#getProgramInfo.PRTITLE[subRowCounter2]#</b><br>

#getProgramInfo.DRFNAME[subRowCounter2]#&nbsp;#getProgramInfo.DRLNAME[subRow
Counter2]#<br>
    #getProgramInfo.DRTITLE[subRowCounter2]#<br>
    #getProgramInfo.DRDEPT[subRowCounter2]#<br>
    #getProgramInfo.DRCOMPANY[subRowCounter2]#
    </td>
    <cfset columnCounter = columnCounter + 1>
    <cfset subRowCounter2 = subRowCounter2 + 1>
    </cfloop>
</tr>

<!--- This Row Displays length of Programs --->
<tr bgcolor="#Request.Lightcolor#">
    <cfset columnCounter = 1>

    <cfloop from="#partcounter#" to="#columnCount#" index="x">
    <td <cfif columnCounter EQ 1 AND rowCounter EQ
#rowCount#>colspan="2"</cfif>>
    <b>Running time: #Evaluate(getProgramInfo.PPLENGTH[subRowCounter3]/60)#
Hour(s).</b>
    </td>
    <cfset columnCounter = columnCounter + 1>
    <cfset subRowCounter3 = subRowCounter3 + 1>
    </cfloop>
</tr>

<!--- This Row Displays links to Programs, RealPlayer, Media Player --->
<tr>
    <cfset columnCounter = 1>

    <cfloop from="#partcounter#" to="#columnCount#" index="x">
    <td <cfif columnCounter EQ 1 AND rowCounter EQ
#rowCount#>colspan="2"</cfif>>
        <a
href="WA/#getProgramInfo.PPREALURL[subRowCounter4]#?PRCODE=#getProgramInfo.P
RCODE#"><img src="images/freeplayer_g2.gif" alt=""
border="0"></a>&nbsp;&nbsp;
    <a
href="WA/#getProgramInfo.PPMEDIAURL[subRowCounter4]#?PRCODE=#getProgramInfo.
PRCODE#"><img src="images/mediaplayer.gif" width="88" height="31"
border="0"></a>
    </td>
    <cfset columnCounter = columnCounter + 1>
    <cfset subRowCounter4 = subRowCounter4 + 1>
    <!--- End Inner Loop --->
    </cfloop>
</tr>
<tr>
    <td colspan="2">&nbsp;</td>
</tr>

<!--- increment outer counters --->
<cfscript>
    rowCounter = rowCounter + 1;
    partcounter = partcounter + 1;
    nextrow = #rowCounter#;
</cfscript>

<!--- End Outer Loop --->
</cfloop>
</cfoutput>
</table>

    </td>
</tr>

<tr>
    <td>&nbsp;</td>
</tr>
</table>


</body>
</html>



Erika
(with a *K*)

"Love gives us in a moment what we can hardly attain by effort after years
of toil." - Goethe

-----Original Message-----
From: Daniel Lancelot [mailto:[EMAIL PROTECTED]]
Sent: Monday, July 16, 2001 6:58 AM
To: CF-Community
Subject: RE: Dynamic Tables


Hi EriKa

what i'd do (OTTOMH - not tested)

Set a temporary val to the number of records to be displayed (countdown)

subtract 1 from current val on each new record

set another temp val to 0 (current record)

add 1 to current val on each new record

use if((currentrecord mod 2 eq 1) and (countdown eq 0)) to find if its a
colspan 2

use if(currentrecord mod 2 eq 0) to find if its the last td in the row.

use if(currentrecord mod 2 eq 1) to find if its the first td in the row.

with a bit more modularisation and slightly diff comparisons you could get
this to display any num of columns correctly...

HTH dan
-----Original Message-----
From: Erika L. Walker [mailto:[EMAIL PROTECTED]]
Sent: 13 July 2001 19:46
To: CF-Community
Subject: SOT: Dynamic Tables


Hello everyone! I hope this finds everyone in good spirits on a Friday...

I am trying to build a page dynamically...but it's a little complicated..

If you take a look at http://www.medmeet.org/medbroadcast/programStart.cfm

You'll see two parts to a test. (Right now it's just hard coded HTML)

The thing is, programs can have anywhere from 1 part to 4 parts or
more....and the client wants to see the parts laid out in a two colum format
as shown, if there are two parts or more....

Now obviously, if there was only one part, then there would only be one
column.... but three would look like this:

-------------
|     |     |
|     |     |
|     |     |
-------------
|           |
|           |   <--- with this row
|           |        being one column
-------------        (colspan of 2)


So my dilema is, besides being brain-fried, is I know how to build dynamic
tables row by row, but column by column, with dynamic colspans? Anybody ever
have to do this before? Can it be done?

Here's the logic I am thinking of:

If program has more than 1 part
        display two columns
else
        colspan = 2



Loop through this logic if parts is greater than 2?

Am I on the right track?

Sorry to be so absent, I am lurking...keeping an eye on everybody, ....
*** miss you horribly ****

Thanks ever so much,



Erika
(with a *K*)

"Love gives us in a moment what we can hardly attain by effort after years
of toil." - Goethe
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-community@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to