Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying query results in 3 column table - within a cfloop

Status
Not open for further replies.

drmixology

Programmer
Feb 16, 2008
1
US
Hello,

I have the following code. I would like the results to be displayed in 3 columns, rather than just 1:

<cfparam name="start" type="numeric" default="1">
<cfparam name="step" type="numeric" default="10">
<cfquery datasource="mydatabase" cachedwithin=".01" name="queryResults">
select *
from tblrecipes
order by recipe_name asc
</cfquery>
<cfif queryResults.recordcount gt 0>
<cfoutput>
<p>
<!--- if past start --->
<cfif (start-step-step) gt 1>
<a href="#cgi.SCRIPT_NAME#?start=1"><img src="images/Beginning_blue.png" alt="Beginning" width="31" height="21" align="absbottom"></a>
</cfif>
<cfif start gt 1>
<a href="#cgi.SCRIPT_NAME#?start=#start-step#"><img src="images/previous_blue.png" alt="Previous" align="absbottom"></a>
</cfif>
<strong>#start# - #iif(start + step gt queryResults.recordcount,queryResults.recordcount,start + step-1)# of #queryResults.recordcount# records</strong>
<!--- if still some not displayed --->
<cfif (start + step) lte queryResults.recordcount>
<a href="#cgi.SCRIPT_NAME#?start=#start+step#"><img src="images/next_blue.png" alt="Next" align="absbottom"></a>
</cfif>
<cfif (start+step+step) lte queryResults.recordcount>
<a href="#cgi.SCRIPT_NAME#?start=#queryResults.recordcount-step+1#"><img src="images/end_blue.png" alt="End" align="absbottom"></a>
</cfif>
</p>
</cfoutput>
</cfif>
<cfloop query="queryResults" startrow="#start#" endrow="#start + step-1#">


<table width="100%" border="1" bordercolor="#FFFFFF" cellspacing="0" cellpadding="2">
<tr>
<cfoutput>
<td width="33%">#queryResults.RECIPE_NAME#</td>
<cfif currentRow mod 3 eq 0>
</tr>
</cfif>
</cfoutput>

</table>

</cfloop>

It displays 10 results per page in one column.... How can I get the results on each page to display in a table with three columns?

Find cocktails at <a href=" Mixology</a>, the new http://www.drmixology.com"]mixology[/URL] community
 
<cfoutput>
<td width="33%">#queryResults.RECIPE_NAME#</td>
<cfif currentRow mod 3 eq 0>
</tr><tr> </cfif>
</cfoutput>

You also have to create two empty cells in the last row, since 10 is not evenly divisible by 3.


Phil H.
Some Bank
-----------
Time's fun when you're having flies.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top