the loop is outside the table because i wanted to have a separate table per 2 
records or per 1 record.  That's the way the graphic designer coded the mockup 
here.
the 2nd line is the error.  I was hoping that someone would be able to help me 
with my looping to remove the erroneous table.

Right now it looks like this:
1   2
2
3   4
4
etc.

it should look like this:
1   2
3   4
etc.

No matter.  I went ahead and converted my query to an array of structures.
Then I iterated through the array.

<cfloop from=1 to=arraylen(myArray) step=2>
<table>
   <tr>
      <td>#myArray[i].fname# #myArray[i].lname#</td>
      <cfif #i# LT #arrayLen(myArray)#>
      <td>#myArray[i+1].fname# #myArray[i+1].lname#</td>
      </cfif>
   </tr>
</table>
</cfloop>

Probably lost some efficiency when converting query to an array, but it sure 
makes life easier in coding this mockup.

Thoughts?  Could I have done this better?

Thanks!
Chris
p.s. you guys are great...i posted in Google Groups and got no responses.


> getfoo is right...
> 
> Not sure if this has already been fixed, but the <cfloop...> tags need 
> to be INside the table tags, so each iteration in the loop creates a 
> new row, not a new table.
> 
> Also, not sure what the purpose of the "cfif currentrow LTE 
> recordcount" is for. The loop will end when the recordset is done, so 
> this is redundant.
> 
> Not sure why they want to show the next row on the current row. 
> Doesn't make sense at all. Especially since it's set to happen every 
> other row... unless they were trying to do something like this, 
> putting two names per line?
> 
        
> <cfif (currentrow mod 2 EQ 0) or (currentrow EQ recordcount)>   
        
> <!--- <td>#getFoo.fname# #getFoo.lname#</td> --->
        
> <cfelse>
        
> <td>#getFoo.fname# #getFoo.lname#</td>
        
> <td>#getFoo.fname[currentrow+1]# #getFoo.lname[currentrow+1]#</td>
        
> </cfif>
> 
> Mik
> 
> 
> At 05:36 PM 5/17/2007, Bobby Hartsfield wrote:
> >Without fixed widths on the cells, they aren?t going to line up in 
> separate
> >tables
> >
> >-----Original Message-----
> >From: Christopher Chin [mailto:[EMAIL PROTECTED] 
> >Sent: Thursday, May 17, 2007 4:55 PM
> >To: CF-Talk
> >Subject: Re: cfloop output into columns - help
> >
> >OK..I have a new issue with the HTML.  My designer just changed the 
> layout
> >on me and I'm having a hard time with the logic for the html.
> >
> >Here is my code:
> ><cfquery name="getFoo" datasource="employees">
> > select * from employees where fname like 'chris%' order by fname, 
> lname
> ></cfquery>
> >
> ><cfloop query="getFoo">
> ><table border="1">
> >   <tr>
> >     <cfif currentrow LTE recordcount>
> >        <cfif (currentrow mod 2 EQ 0) or (currentrow EQ recordcount)>   
> 
> >        <td>#getFoo.fname# #getFoo.lname#</td>
> >        <cfelse>
> >        <td>#getFoo.fname# #getFoo.lname#</td>
> >        <td>#getFoo.fname[currentrow+1]# #getFoo.
> lname[currentrow+1]#</td>
> >        </cfif>
> >     </cfif>
> >   </tr>
> ></table>
> ></cfloop>
> >
> >The difference now is that there's one table per record in the query.  
> the
> >table has either 1 or 2 columns based on the # of results.
> >
> >see it in action here: http://www.christopherchin.com/cflooptest2.
> cfm
> >
> >any help with the logic is much appreciated :O)
> >
> >thanx!
> >Chris
> 
> --------
> Michael Muller
> Admin, MontagueMA.net Website
> work (413) 863-0030
> cell (413) 320-5336
> skype: michaelBmuller
> http://www.MontagueMA.net
> 
> Eschew Obfuscation
> 
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Create robust enterprise, web RIAs.
Upgrade & integrate Adobe Coldfusion MX7 with Flex 2
http://www.adobe.com/products/coldfusion/flex2/?sdid=RVJP

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:278529
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to