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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

return querey in rows and columns

Status
Not open for further replies.

peter11

Instructor
Mar 16, 2001
334
US
I have a query that returns 30 names. I want the output to be 10 rows and three columns. I am sure there is a simple answer but it is alluding me.

Jeff
 
Like this...

Code:
<cfset crow=0>
<table>
  <cfoutput query="query_name">
    <cfset crow=1+1>
    <Cfif crow eq 1><tr></cfif>
      <td>#var_name#</td>
    <cfif crow eq 3></tr><cfset crow=0></cfif>
  </cfoutput>
  <cfif crow eq 1><td colspan="2">&nbsp;</td></tr>
  <cfelseif crow eq 2><td>&nbsp;</td></tr></cfif>
</table>

query_name is the name of your query
#var_name# is where you put the variable containing the name.

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
I understand the code and the concept but it just returns one long row.

 
THnaks,
I just modified your code a little.
<cfoutput query="queryname">
<Cfif currentrow mod 3 eq 1><tr></cfif>
<td>#firstname# #lastname#</td>
<cfif currentrow mod 3 eq 0></tr></cfif>
</cfoutput>
 
haha, my mistake!

Code:
<cfset crow=0>
<table>
  <cfoutput query="query_name">
    <cfset crow=[b]crow[/b]+1>
    <Cfif crow eq 1><tr></cfif>
      <td>#var_name#</td>
    <cfif crow eq 3></tr><cfset crow=0></cfif>
  </cfoutput>
  <cfif crow eq 1><td colspan="2">&nbsp;</td></tr>
  <cfelseif crow eq 2><td>&nbsp;</td></tr></cfif>
</table>

Glad you've got something working for you though

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
Check FAQ: faq232-3697

DeZiner
Never be afraid to try something new.
Remember that amateurs built the Ark.
Professionals built the Titanic
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top