Skip to main content
Inspiring
March 20, 2008
Question

How i display this way?.

  • March 20, 2008
  • 3 replies
  • 353 views
How can i display this output using cfoutput?

    This topic has been closed for replies.

    3 replies

    Participating Frequently
    March 20, 2008
    For the first one what I would suggest is using an array to transform the data first and make the output later. :)

    I will try it whenever I find some time. :)
    Inspiring
    March 20, 2008
    Javagene wrote:
    > How can i display this output using cfoutput?
    >
    > Depatment ID Department Name Depatment ID Department
    > Name
    > 1 Math 4 Geology
    > 2 Biology 5 Space
    > 3 History 6 Ocenology

    By not using <cfoutput...> loop but a more basic <cfloop...> loop.

    <cfoutput>
    <cfloop from="1" to="#dept_q.recordCount#" index="record" step="2">
    <tr>
    <td>
    #dept_q.dept_id[record]# 
    #dept_q.dept_name[record]#</a>
    </td>
    <td>
    <cfif record + int(dept_q.recordCount/2) LTE dept_q.recordCount>
    #dept_q.dept_id[record + int(dept_q.recordCount/2)]# 
    #dept_q.dept_name[record + int(dept_q.recordCount/2)]#</a>
    </cfif>
    </td>
    </tr>
    </cfloop>
    </cfoutput>

    > Same way...how i dispaly this output using cfoutput?
    > Depatment ID Department Name Depatment ID Department
    > Name
    > 1 Math 2 Biology
    > 3 History 4 Geology
    > 5 Space 6 Ocenology
    >

    With the correct application of the mod operator.

    > <cfoutput query="dept_q">
    > <tr>
    > <td>#dept_id# #dept_name#</a></td>
    > <td>#dept_id# #dept_name#</a></td>
    <cfif dept_q.currentRow MOD 2 EQ 0>
    </tr>
    <tr>
    </cfif>
    > </tr>
    > </cfoutput>


    Participating Frequently
    March 20, 2008
    Here is a general solution but I think for the second one.

    <cfset myTotalRows = 2>
    <table>
    <tr>
    <cfoutput query="dept_q">

    <td>#dept_id# #dept_name#</a></td>
    <td>#dept_id# #dept_name#</a></td>
    <cfif currentrow MOD myTotalRows EQ 0>
    </tr>
    <tr>
    </cfif>
    </cfoutput>
    </tr>
    </table>