Helpful Information
 
 
Category: ColdFusion Development
output 1 column into separate html tables

HELP. I am new to CF and I am stumped!!

I have only one column in a database that I need to "divide", preferably in half, but this will not be possible if I have an odd number of records. I want to output 1/2 of column 1 in its own html table, and I'd like to output the other half of column 1 in its own html table, on separate parts of the page. These HTML tables will be independent of each other because there will be information on the web page in between these two html tables.

Do I need two queries, instead of one??

Therefore it would be something like this:

<td>
<table><!---1/2 of column 1 on left side of page--->
A
B
C
</table>
</td>

<td>
<table>
<!---nondatabase information--->
</table>
</td>

<td>
<table>
<!---1/2, or the remainder of column 1 on right side of html page--->
D
E
F
G
</table>
</td>

PLease, anyone, can you help?
THANKS IN ADVANCE!

You could do something like this.



<cfoutput query="queryname" startrow="1" maxrows="5">
#variables.name#
</cfoutput>

<cfoutput query="queryname" startrow="6" maxrows="10">
#variables.name#
</cfoutput>


That what your looking for?

Thanks For Your Response. I was unaware of the startrow and maxrow features (I am a newbie!).

Someone on another list answered this for me in a similar fashion.

I'll post for anyone else having a similar problem:

<!--- Get the data --->
<cfquery name="qryName" ..>
SELECT *
FROM tblName
</cfquery>

<!--- Set vars --->
<cfset locTotalRecordCount=qryName.RecordCount>
<cfset locMaxRows=Ceiling(locTotalRecordCount / 2)>
<cfset locStartRow=1>

<td>
<table><!---1/2 of column 1 on left side of page--->
<cfoutput query="qryName" startrow="#locStartRow#" maxrows="#locMaxRows#">
<tr><td>#qryName.var#</td></tr>
<!--- Increment the locStartRow var --->
<cfset locStartRow=locStartRow + 1>
</cfoutput>
</table>
</td>

<td>
<table>
<!---nondatabase information--->
</table>
</td>

<td>
<table>
<cfoutput query="qryName" startrow="#locStartRow#" maxrows="#locMaxRows#">
<tr><td>#qryName.var#</td></tr>
</cfoutput>
</table>
</td>










privacy (GDPR)