This code should work great for what you need,
of course change all of the MyQuery references to your query name
<!--- Identify how many images across you want --->
<cfset CellsPerRow = 4>
<table border="1">
<tr>
<cfoutput query="MyQuery">
<td>cell #MyQuery.currentrow#<!--- Place Whatever you wanted to
display in this cell ---></td>
<cfif MyQuery.currentrow mod CellsPerRow eq 0></tr><tr></cfif>
</cfoutput>
<cfif MyQuery.recordcount mod CellsPerRow neq 0>
<cfset current_cell = MyQuery.recordcount>
<cfset addcell = 0>
<cfscript>
while (current_cell mod CellsPerRow neq 0)
{
addcell = addcell + 1;
current_cell = current_cell + 1;
}
</cfscript>
<cfloop from="1" to="#addcell#" index="x">
<td><!--- Place Whatever you wanted in the leftover cells
---> </td>
</cfloop>
</cfif>
</tr></table>
-----Original Message-----
From: Patricia Lee [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 16, 2001 4:29 PM
To: CF-Talk
Subject: RE: Formatting CFQUERY Results in a Table
Just a comment
Nice... but it will cause improper HTML if the query results are evenly
divisible by the var your're using to Mod with.... Here's the results of a
table generated with this forumula... notice the extra </tr><tr> combo. If
you needed to display these results in netscape.... well, I don't have
netscape on my computer anymore to check, but we all know how picky she is.
<table border="1">
<tr>
<td>Carolynn</td>
<td>Dave</td>
<td>Linda</td>
<td>Aaron</td>
</tr> <tr>
</tr>
</table>
I remember having to do something similar myself, and I think I got it to
work and still generate proper html... but it was a mess. Worse I can't
remember how I did it now to whip out for comparison.
|-----Original Message-----
|From: Nathan Stanford [mailto:[EMAIL PROTECTED]]
|Sent: Friday, March 16, 2001 3:09 PM
|To: CF-Talk
|Subject: RE: Formatting CFQUERY Results in a Table
|
|
|
|
|
|This can be found on my website in Issue 00001
|
|I. ColdFusion Code: Output Text in 2,3,4,... Rows
|You can just modify the number 4 after the MOD
|and change the yourquery to whatever you query name
|is and of course the var to your own var.
|
|<table>
| <tr>
| <cfoutput query="yourquery">
| <td>#var#</td>
| <cfif yourquery.CurrentRow MOD 4 IS 0>
| </tr> <tr>
| </cfif>
| </cfoutput>
| </tr>
|</table>
|
|
|
|
|
|> -----Original Message-----
|> From: James Birchler [SMTP:[EMAIL PROTECTED]]
|> Sent: Friday, March 16, 2001 1:27 PM
|> To: CF-Talk
|> Subject: Formatting CFQUERY Results in a Table
|>
|> Hi Gang -
|>
|> I'm building an employee directory, and am adding a page
|that displays all
|> employee photos so that if you don't know someone's name,
|you can find it
|> by
|> recognizing their face. My query pulls an image url and
|fname/lastname
|> from
|> a database.
|>
|> I'm trying to format the output in table rows, with each row
|containing 4
|> table cells (each with one photo displayed).
|>
|> How do I let CF know when to create another table row? So
|far I can make
|> one
|> really long row, or one really long column!
|>
|> Is the answer on the SQL side (using LIMIT or COUNT) or on
|the CF side, or
|> both? Any suggestions much appreciated.
|>
|> Thanks,
|>
|> James
|>
|>
|>
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists