Skip to main content
Mar 22, 2013 7:23 PM UTC
Question

How to display?

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 is closed to new replies. Start a new post to keep the conversation going.

    8 replies

    Inspiring
    Mar 22, 2013 10:10 PM UTC

    <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.

    Translate
    BreakawayPaul
    Inspiring
    Mar 22, 2013 10:17 PM UTC

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

    Translate
    Inspiring
    Mar 23, 2013 12:29 AM UTC

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

    Translate
    BreakawayPaul
    Inspiring
    Mar 22, 2013 9:52 PM UTC

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

    <ol>

    <cfoutout query="queryname">

    <li>#itemname#</li>

    </cfoutput>

    </ol>

    Translate