5 Replies Latest reply on Jan 28, 2010 11:14 AM by Irish-Phoenix

    problems getting cfloop to output in 2 columns.

    Irish-Phoenix Level 1

      Hello;

      I'm having a problem making my code actually output properly. It's not throwing any errors, it actually says there is a record to be read, but my output from my cfloop is wrong I believe. I'm trying to make it break down into 2 columns like this

       

      1 2

      3 4

      NEXT >

       

      once there is 4 records, the button to go to next page comes up. I know this code is bulky, AI also know my query and next n buttons work fine, so I'm going to post just the query, and the loop with the statements to break it down into 2 columns.

      Code:

      <cfquery name="newsStory" datasource="#APPLICATION.dataSource#" maxRows=10>
      SELECT klNews.title AS ViewField2, klNews.newsDate AS ViewField3, klNews.MYFile, klNews.MYFile2, klNews.ID AS ID
      FROM klNews
          ORDER BY newsDate
      </cfquery>

       

      <cfset halfrecords = newsStory.RecordCount/2>

      <cfloop query="newsStory" startRow="#URL.startRow#" endRow="#endRow#">
      <cfoutput>
         <tr>
      <cfif CurrentRow lte halfrecords>

      <td width="49%" align="center" valign="top">

      #All my content is in here for column 1#

      </td>
      </cfif>
      <cfif Evaluate(CurrentRow+halfrecords) lte newsStory.RecordCount>
      <td width="2%" align="center" valign="top">  </td>
      <td width="49%" align="center" valign="top">

      #column 2 stuff is here#

      </cfif>
      </tr>
      </cfoutput></cfloop>

       

      it's not showing anything at the moment,
      Thank you.