#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Location
    Summervile, SC
    Posts
    115
    Rep Power
    13

    little coding prob...


    ok, this here is my code:

    Code:
    <table width="90%" cellpadding="5" cellspacing="5" border="1">
    	
    	<tr>
    		<cfoutput query="myquery" group="category">
    		<td width="33%" valign="top">
    			
    			<p align="center"><strong>#category#</strong></p>
    			
    			<cfoutput>
    			#field1#, #field2#
    			<hr>
    			</cfoutput>
    		</td>
    			<cfif not myquery.currentRow MOD 3>
    	</tr>
    	<tr>
    			</cfif>
    			</cfoutput>
    	</tr>
    </table>
    usually this would output my query results in 3 columns, but apparantly the grouping is throwing this off, it comes out in this hideous mass of cells all over the place.

    anyone know how to fix this????

    thanks!

    later
  2. #2
  3. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,265
    Rep Power
    968
    I'm not sure what format you're trying for? Do you want 3 table columns? Like this?

    <tr>
    <td>category1<td>
    <td>field1<td>
    <td>field2<td>
    </tr>

    Keep in mind that to use the "group" attribute you must be ordering your query by that column as well.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Location
    Summervile, SC
    Posts
    115
    Rep Power
    13
    no, like this:

    <tr>
    <td>
    category1

    field1, field2
    </td>

    <td>
    category2

    field1, field2
    </td>

    <td>
    category3

    field1, field2
    </td>
    </tr>

    <tr>
    <td>
    category4

    field1, field2
    </td>

    <td>
    category5

    field1, field2
    </td>

    <td>
    category6

    field1, field2
    </td>
    </tr>

    thanks!
  6. #4
  7. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,265
    Rep Power
    968
    Well then, as long as your query is ordered by category, you should be able to do it like this:

    <table>
    <cfoutput query="myquery" group="category">
    <tr>
    <td>
    #myQuery.category#
    <cfoutput>
    #field1# #field2#
    </cfoutput>
    </td>
    </tr>
    </cfoutput>
    </table>

    Basically everything inside the outer cfoutput block, but not inside the inner cfoutput block, will only execute once for each category. But the code in the inner cfouput block will execute for each data row present for each category.
    Last edited by kiteless; January 15th, 2004 at 12:33 PM.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Location
    Summervile, SC
    Posts
    115
    Rep Power
    13
    ok, maybe a visual aid will help...

    i don't want my table like this:


    but like this:


    does this help??

    thanks again!!

    later

IMN logo majestic logo threadwatch logo seochat tools logo