Solved

Wanna Create a TD based on Coldfusion

Posted on 2009-07-11
3
166 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
  • 2
3 Comments
 
LVL 13

Expert Comment

by:srikanthmadishetti
ID: 24831588
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
ID: 24831701
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 16

Author Closing Comment

by:Gurpreet Singh Randhawa
ID: 31602450
Worked Thanks
0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Summernote required 3 189
Grunt No Clean Targets 6 192
REGEX HELP 11 49
ajaxSubmit is giving me an error 1 47
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
The purpose of this video is to demonstrate how to automatically show related posts at the bottom of a blog post in WordPress. This will be demonstrated using a Windows 8 PC. Plugin “Yet Another Related Posts Plugin” will be used. Go to your…
The purpose of this video is to demonstrate how to set up the permalinks on a WordPress Website. 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 : Go t…

830 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