|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I need to display the results a query 3 columns across then drop down to the next row and display the rest of the info and so on...
#1 #2 #3 #4 #5 #6 #7.................... and so on... here's the code I'm trying to use.. It kinda works... I can't display the last record. <cfset i = 1> <cfloop query="FAVORITES" startrow="#i#" endrow="#i+1#"> <cfoutput> <tr> <td><img src="images/artists/#FAVORITESPHOTO[i]#" width="65"></td> <td><font color="CC6600"><b>#FAVORITESARTIST[i]#</b></font><br>#FAVORITESLOCATION[i]#</td> <td><img src="images/artists/#FAVORITESPHOTO[i+1]#" width="65"></td> <td><font color="CC6600"><b>#FAVORITESARTIST[i+1]#</b></font><br>#FAVORITESLOCATION[i+1]#</td> <td><img src="images/artists/#FAVORITESPHOTO[i+2]#" width="65"></td> <td><font color="CC6600"><b>#FAVORITESARTIST[i+2]#</b></font><br>#FAVORITESLOCATION[i+2]#</td> <cfset i = i+3> </cfoutput> </cfloop> bloodfest |
|
#2
|
|||
|
|||
|
Here is a simple example that uses the modulus operator, which returns the remainder of the first value divided by the second. When the remainder is 1 you know you're at the start of the row, and when the remainder is 0 you know you're at the end of the row.
<cfoutput> <table border="1"> <cfloop index="i" from="1" to="12"> <cfif i mod 3 eq 1> <tr> </cfif> <td>#i# - #i mod 3#</td> <cfif i mod 3 eq 0> </tr> </cfif> </cfloop> </table> </cfoutput>
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#3
|
|||
|
|||
|
Almost...
<cfoutput>
<table border="1"> <cfloop index="i" from="1" to="12"> <cfif i mod 3 eq 1> <tr> </cfif> <td>#FAVORITESARTIST[i]#</td> <cfif i mod 3 eq 0> </tr> </cfif> </cfloop> </table> </cfoutput> I tried this but it repeat the query 8 times... so I got all the records.. 8 times.. |
|
#4
|
|||
|
|||
|
Is "favoriteartist" a query? If so, why not just use the normal query syntax ie "myqueryname.mycolumnname"?
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > data placement... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|