Solved

Wanna Create a TD based on Coldfusion

Posted on 2009-07-11
3
163 Views
Last Modified: 2013-12-24
Hi experts, I have many as 10 images and i want all the images appear in 5 in one row. i am really out done how i do.

Please can someone correct my code:
<cfif DirectoryExists("#ExpandPath("images/#username#/watermarked")#")>

     <cfdirectory action="list" directory="#ExpandPath("images/#username#/watermarked")#" name="showall">

	<cfset dirsArray=arraynew(1)>

	<cfset i=1>

    <cfloop query="showall">

    <cfif showall.type IS "file">

    <cfset dirsArray[i]=showall.name>

    <cfset i = i + 1>

    </cfif>

    </cfloop>

    <cfset variables.newrow = False>

     <table border="1">

     <cfloop from="1" to="#ArrayLen(dirsArray)#" index="i">

     <cfoutput>

     

            <cfif variables.newrow EQ true>

              <tr>

            </cfif>

            <td><input type="radio" name="oldimage#i#" value="#dirsArray[i]#" /><strong>

     <img src="images/#GetA.username#/watermarked/#dirsArray[i]#" border="0" width="100" height="100" /></strong>

     </td>

            <cfif showall.currentRow MOD 3 EQ 0>

              </tr>

              <cfset variables.newrow = true>

              <cfelse>

              <cfset variables.newrow = false>

            </cfif>    

     

     </cfoutput>

     </cfloop>

     </table>        

     </cfif>

Open in new window

0
Comment
Question by:myselfrandhawa
  • 2
3 Comments
 
LVL 13

Expert Comment

by:srikanthmadishetti
Comment Utility
see this example


<cfset test = "a,b,c,d,e,f,g,h,i,j">
<cfoutput>

<table width="100%" border="1">
<tr>
<cfset count = 1>
<cfloop list="#test#" index="i">
<td>
#i#  #listlen(test) mod 5#
</td>
<cfif count mod 5 eq 0>
</tr>
<tr>
</cfif>

<cfif count eq  listlen(test)>
</tr>
</cfif>

<cfset count = count +1>
</cfloop>

</table>
</cfoutput>

in the above example i used list instead of query

you can use queryname.recordcount  instead of listlen(test) and insetad of coutn you can use currentrow.
0
 
LVL 13

Accepted Solution

by:
srikanthmadishetti earned 500 total points
Comment Utility
I have modifed didn't tested but it should work .

Let me know if u have any props.

 <cfoutput>
<cfif DirectoryExists("#ExpandPath("images/#username#/watermarked")#")>
     <cfdirectory action="list" directory="#ExpandPath("images/#username#/watermarked")#" name="showall">
        <cfset dirsArray=arraynew(1)>
        <cfset i=1>
    <cfloop query="showall">
    <cfif showall.type IS "file">
    <cfset dirsArray[i]=showall.name>
    <cfset i = i + 1>
    </cfif>
    </cfloop>
 
     <table border="1">
      <tr>
     <cfloop from="1" to="#ArrayLen(dirsArray)#" index="i">
    <td><input type="radio" name="oldimage#i#" value="#dirsArray[i]#" /><strong>
     <img src="images/#GetA.username#/watermarked/#dirsArray[i]#" border="0" width="100" height="100" /></strong>
     </td>
 <cfif i mod 5 eq 0>
</tr>
<tr>
</cfif>
     
     <cfif i eq  ArrayLen(dirsArray)>
</tr>
</cfif>
 
     </cfloop>
     </table>        
     </cfif>
     
         </cfoutput>
0
 
LVL 15

Author Closing Comment

by:myselfrandhawa
Comment Utility
Worked Thanks
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
The purpose of this video is to demonstrate how to connect a WordPress website to Google Analytics. This will be demonstrated using a Windows 8 PC Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php :…
The purpose of this video is to demonstrate how to manually back up a WordPress Database. This will be demonstrated using a Windows 8 PC. The Host used will be IPage.com Log into your Hosting account. IPage will be used for demonstration : Locat…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now