Skip navigation
Kalle4001
Currently Being Moderated

CurrentRow MOD And Br

Jun 1, 2012 3:16 AM

hello I'm trying to get a loop. The idea is to just

create a table that shows 2 row and 5 column.

 

 

Instead of

1

2

3

4

a.s.o

 

 

I want

12345

space writable

678910

 

 

I've made a CurrentRow MOD and it working right to left, but

not the space

 

even if it is possible to loop the table instead of the columns

 

 

<table width="500" border="1">

<tr><cfoutput query="testrec" startRow="#StartRow_testrec#" maxRows="#MaxRows_testrec#">

<td>#testrec.tblOnskelista# </td>

<CFIF testrec.CurrentRow MOD 5 IS 0>

 

</TR>

<TR></TR>

</CFIF>

</cfoutput>

</table>

 
Replies
  • Currently Being Moderated
    Jun 1, 2012 4:36 AM   in reply to Kalle4001

    I think you'll find an empty <tr> doesn't - intrinsically - have any height.

     

    --
    Adam

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 1, 2012 8:57 AM   in reply to Kalle4001

    In the spot where you want your space, add a set of td tags containing a non breaking space.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 1, 2012 9:49 AM   in reply to Kalle4001

    I saw this exact same question on another forum: http://www.codingforums.com/showthread.php?t=263220

     

    ^_^

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 1, 2012 10:10 AM   in reply to Kalle4001

    I tend to avoid the MOD calculation in a loop like this and instead use two loops:

    <table>
      <cfloop index="variables.i" from="#StartRow_testrec#" to="#EndRow_testrec#" step="5">
       <tr>
        <cfloop index="variables.y" from="#variables.i#" to="#variables.i+5#">
         <td><cfif variables.y LTE testrec.rowCount>#testrec.tblOnskelista[variables.y]#<cfelse> </cfif> </td>
        </cfloop>
       </tr>
      </cfloop>
    </table>
     
    |
    Mark as:
  • Currently Being Moderated
    Jun 4, 2012 1:46 AM   in reply to Kalle4001

    Couldn't you just do something as simple as this

     

    <table width="500" border="1">

    <tr>

    <cfoutput query="testrec" startRow="1" maxRows="5">

    <td>#testrec.tblOnskelista# </td>

    </cfoutput>

    </tr>

    </table>

    <br>

    <table width="500" border="1">

    <tr>

    <cfoutput query="testrec" startRow="6" maxRows="5">

    <td>#testrec.tblOnskelista# </td>

    </cfoutput>

    </tr>

    </table>

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 4, 2012 5:29 AM   in reply to Kalle4001

    Kalle4001 wrote:

     

    i get wront when i start next 10 record

     

    <a href="<cfoutput>#CurrentPage#?PageNum_testrec=#Min(IncrementValue(Pag eNum_testrec),TotalPages_testrec)##QueryString_testrec#</cfoutput>">N e xt</a>

     

    now you say only the first 10

     

    This is apparently a new question. Have you resolved the first one?

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 4, 2012 11:48 PM   in reply to Kalle4001

    You can just add if-conditions to control output according to the number of records. Here are examples:

     

    (1)

    <cfif testrec.recordcount GTE 1>

    <table width="500" border="1">

    <tr>

    <cfoutput query="testrec" startRow="1" maxRows="5">

    <td>#testrec.tblOnskelista# </td>

    </cfoutput>

    </tr>

    </table>

    </cfif>

     

    <br>

     

    <cfif testrec.recordcount GTE 6>

    <table width="500" border="1">

    <tr>

    <cfoutput query="testrec" startRow="6" maxRows="5">

    <td>#testrec.tblOnskelista# </td>

    </cfoutput>

    </tr>

    </table>

    </cfif>

     

    (2)

    <cfif testrec.recordcount GTE 11>

    <cfoutput query="testrec" startRow="11" maxRows="8">

    <cfset link = CurrentPage & "?PageNum_testrec=" & Min(IncrementValue(PageNum_testrec),TotalPages_testrec) & QueryString_testrec>

    <a href="#link#">Next</a><br>

    </cfoutput>

    </cfif>

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 5, 2012 12:49 AM   in reply to Kalle4001

    I am assuming that your query is called testrec.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 5, 2012 3:50 AM   in reply to Kalle4001

    Then testrec.recordcount should exist! Make sure you put the above code in a position where the query is defined. For example, right after the cfquery tag.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points