Solved

Wanna Create a TD based on Coldfusion

Posted on 2009-07-11
3
165 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…
The purpose of this video is to demonstrate how to Import and export files in WordPress. 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 : Click on Too…

816 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

10 Experts available now in Live!

Get 1:1 Help Now