Solved

Wanna Create a TD based on Coldfusion

Posted on 2009-07-11
3
168 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

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 …
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
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 integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…

726 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