Skip to main content
March 22, 2013
Question

How to display?

  • March 22, 2013
  • 2 replies
  • 1074 views

My query returns item list.

select itemname from tbl_list

i want to disply like this

1.     L0125   #itemname#

2.     L0126  #itemname#

3.     L0127  #itemname#

4.     L0128  #itemname#

example...

1.     L0125   Pen

2.     L0126   Book

    This topic has been closed for replies.

    2 replies

    Inspiring
    March 22, 2013

    <cfif queryName.recordcount neq 0>

    <cfset start = 125 />

         <ol>

              <cfloop query="queryName">

                   <li>L#numberFormat( start, '0000' )# #itemName#</li>

              </cfloop>

         </ol>

    </cfif>

    This should take into account that no OL will be written if it contains no records, and you must manually set the start variable, as it seems arbitrary in your output.  The numberFormat() BIF will ensure that numbers lower than 1000 have a prefixed 0 when output.  If it's a field name instead, remove that code/reference and just output the field name.

    BreakawayPaul
    Inspiring
    March 22, 2013

    Aegis, your code has no <cfoutput>, so I think it'll just display as text and not the actual values of the variables.

    Inspiring
    March 23, 2013

    Good point.  I was so used to my pages having a global CFOUTPUT. 

    BreakawayPaul
    Inspiring
    March 22, 2013

    Where's the L0125, L0126, etc.  coming from?  For the rest, you could do:

    <ol>

    <cfoutout query="queryname">

    <li>#itemname#</li>

    </cfoutput>

    </ol>