Return to Snippet

Revision: 66874
at July 15, 2014 23:01 by dreamstarter


Initial Code
<!--- Number of columns per row ---> 
			<cfset NumCols = 2> 
			<cfset tableBGColor = "99AF26">            <!--- any hex value - --> 
			<cfset tablealign = "left">                    <!--- right, left, center ---> 
			<cfset trBGColor = "D6E0A1">                <!--- any hex value ---> 
			<cfset tdBGColor = "D6E0A1">                <!--- any hex value ---> 
			<cfset tdHighlightColor = "D6E0A1">    <!--- any hex value ---> 
			<cfset tdEmptyCell = "D6E0A1">            <!--- any hex value ---> 
			<cfset table_cellpadding = 4>                <!--- numerical value ---> 
			<cfset table_cellspacing = 1>                <!--- numerical value ---> 
			<cfset table_width = 455>                    <!--- numerical value, (1-100 for percent width)---> 
			<cfset table_width_type = "">                <!--- "%" for percentage or leave blank for pixel width ---> 
			<cfset query = "getSponsors">                <!--- query name ---> 
			<cfset ColWidth = Fix(100/NumCols)> 
			<cfoutput>
				<table border="0" cellpadding="#table_cellpadding#" cellspacing="#table_cellspacing#" width="#table_width##table_width_type#" bgcolor="#tableBGColor#" align="#tablealign#">
					<tr valign="top" bgcolor="#trBGColor#">
						<cfloop query="#query#">
							<td align="center" width="#ColWidth#%" bgcolor="#tdBGColor#"> 
								<!--- begin: cells containing content---> 
								    <a href="?sid=#spn_id#" title="Click here to view more information about this sponsor.">#spn_name#</a><br> 
								<!--- end: cells containing content--->
							</td> 
							<cfif (Evaluate(query&".CurrentRow") MOD NumCols) IS 0 AND (Evaluate(query&".CurrentRow") NEQ Evaluate(query&".RecordCount"))>
								</tr>
								<tr valign="top" bgcolor="#trBGColor#">
							</cfif>
						</cfloop>
						<cfif Evaluate(query&".RecordCount") MOD NumCols GT 0>
							<cfset Variables.NumMissingCells = NumCols - (Evaluate(query&".RecordCount") MOD NumCols)>
								<cfloop from="1" to="#Variables.NumMissingCells#" index="iCell"> 
									<!--- begin: padding cells ---> 
									<td bgcolor="#tdEmptyCell#">&nbsp;</td> 
									<!--- end: padding cells ---> 
								</cfloop>
						</cfif>
					</tr>
				</table>
				<br>
			</cfoutput> 
			<!--- Number of columns per row --->

Initial URL

                                

Initial Description
coldfusion snippet to output a query recordset into multiple columns

Initial Title
Query output into multiple columns

Initial Tags
query

Initial Language
ColdFusion