No, he knew what he meant.  Made sense to me.

His code was like this:

<CFOUTPUT QUERY="myQuery ">
         <CFIF myQuery.recordcount MOD 2>
                 <!--- Display all elements for 2 column --->
         <CFELSE>
                 <!--- Display all elements for 1 column --->
         </CFIF>
 </CFOUTPUT>

However if the query has an odd number of records, it'll output the
whole thing in one column. It'll only give you two columns if there's
an even number of records.  I dont think that's what the original
poster wanted.

I think the process should go like this (Untested but I think it should work):

<!----[ Figure out how many records should be in each column ]---->
<cfset columnlength = myQuery.recordcount/2 />
<!----[ if there is an odd number of records, add 1 to the first
column to make it the longer of the two ]---->
<cfif myQuery.recordcount MOD 2>
  <cfset columnlength = columnlength + 1 />
</cfif>
<!----[ Output the records for the first column ]---->
<div id="leftcolumn">
<cfoutput query="myQuery" startrow="1" maxrows="#columnlength#">
#rowstuff# <br />
</cfoutput>
</div>
<!----[ Output the records for the second column. ]---->
<div id="rightcolumn">
<cfoutput query="myQuery" startrow="#columnlength +1#">
#rowstuff# <br />
</cfoutput>
</div>


And if you're still in the early 2000s and using tables for layout,
you'll get this for output:

<table>
  <tr>
<td>
row 1
row 2
row 3
row 4
row 5
</td>
<td>
row 6
row 7
row 8
row 9
row 10
</td>
</tr>
</table>

Or if you've moved into the 21st century and are using CSS based
layouts, you'll get something like this:

<div id="leftcolumn">
row 1
row 2
row 3
row 4
row 5
</div>
<div id="rightcolumn">
row 6
row 7
row 8
row 9
row 10
</div>

Cheers
Mike Kear
Windsor, NSW, Australia
Certified Advanced ColdFusion Developer
AFP Webworks
http://afpwebworks.com
ColdFusion, PHP, ASP, ASP.NET hosting from AUD$15/month


On 4/8/06, Denny Valliant <[EMAIL PROTECTED]> wrote:
> I think you meant:
> <cfloop query="myQuery">
>  <if currentrow MOD 2>
>    all row one data
>  <cfelse>
>    all row two data (or is that backwards? ;)
>  </cfif>
> </cfloop>
>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:237222
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to