This is the three columns I am trying to split it into #category#
#skill#

#category#
#skill#

#category#
#skill#

[allowsmilie] => 1 [showsignature] => 0 [ipaddress] => [iconid] => 0 [visible] => 1 [attach] => 0 [infraction] => 0 [reportthreadid] => 0 [isusenetpost] => 1 [msgid] => [ref] => [htmlstate] => on_nl2br [postusername] => jmoshier [ip] => webforumsuser@m [isdeleted] => 0 [usergroupid] => [membergroupids] => [displaygroupid] => [password] => [passworddate] => [email] => [styleid] => [parentemail] => [homepage] => [icq] => [aim] => [yahoo] => [msn] => [skype] => [showvbcode] => [showbirthday] => [usertitle] => [customtitle] => [joindate] => [daysprune] => [lastvisit] => [lastactivity] => [lastpost] => [lastpostid] => [posts] => [reputation] => [reputationlevelid] => [timezoneoffset] => [pmpopup] => [avatarid] => [avatarrevision] => [profilepicrevision] => [sigpicrevision] => [options] => [akvbghsfs_optionsfield] => [birthday] => [birthday_search] => [maxposts] => [startofweek] => [referrerid] => [languageid] => [emailstamp] => [threadedmode] => [autosubscribe] => [pmtotal] => [pmunread] => [salt] => [ipoints] => [infractions] => [warnings] => [infractiongroupids] => [infractiongroupid] => [adminoptions] => [profilevisits] => [friendcount] => [friendreqcount] => [vmunreadcount] => [vmmoderatedcount] => [socgroupinvitecount] => [socgroupreqcount] => [pcunreadcount] => [pcmoderatedcount] => [gmmoderatedcount] => [assetposthash] => [fbuserid] => [fbjoindate] => [fbname] => [logintype] => [fbaccesstoken] => [newrepcount] => [vbseo_likes_in] => [vbseo_likes_out] => [vbseo_likes_unread] => [temp] => [field1] => [field2] => [field3] => [field4] => [field5] => [subfolders] => [pmfolders] => [buddylist] => [ignorelist] => [signature] => [searchprefs] => [rank] => [icontitle] => [iconpath] => [avatarpath] => [hascustomavatar] => 0 [avatardateline] => [avwidth] => [avheight] => [edit_userid] => [edit_username] => [edit_dateline] => [edit_reason] => [hashistory] => [pagetext_html] => [hasimages] => [signatureparsed] => [sighasimages] => [sigpic] => [sigpicdateline] => [sigpicwidth] => [sigpicheight] => [postcount] => 1 [islastshown] => [isfirstshown] => 1 [attachments] => [allattachments] => ) --> Split grouped query into columns - Coldfusion - Advanced Techniques

Split grouped query into columns - Coldfusion - Advanced Techniques

Hi, I am having a little problem splitting a grouped query into 3 columns. What I am trying to do is group a list of skills under their category and then display them in 3 columns. The two tables I am using is a skill table that contains: skill_id, skill and category_id category table that contains: cateogry_id, category Attached is my query code and the group output I have done so far. I obvisouly have not figured out where to put the startrows and maxrows so the three columns right now output the entire query three times. Any help would ...

  1. #1

    Default Split grouped query into columns

    Hi,
    I am having a little problem splitting a grouped query into 3 columns. What I
    am trying to do is group a list of skills under their category and then display
    them in 3 columns.

    The two tables I am using is a
    skill table that contains: skill_id, skill and category_id
    category table that contains: cateogry_id, category

    Attached is my query code and the group output I have done so far.
    I obvisouly have not figured out where to put the startrows and maxrows so the
    three columns right now output the entire query three times. Any help would
    greatly be appreciated.
    Thanks
    jmoshier

    <cfquery name="GetSkill" datasource="#DSN#">
    SELECT s.*, c.category
    FROM si_skill s
    INNER JOIN si_skill_category c ON s.category_id = c.category_id
    ORDER BY c.category, s.skill
    </cfquery>
    <!---set column variables--->
    <cfset col_len = Ceiling(Getskill.recordcount / 3)>
    <cfset column2 = col_len + 1>
    <cfset column3 = (col_len * 2) + 1>


    This is the three columns I am trying to split it into
    <td width="34%" valign="top">
    <cfoutput query="GetSkill" group="category">
    <strong>#category#</strong><br>
    <cfoutput>
    <input type="checkbox" name="skill" value="#skill_id#"> #skill#<br>
    </cfoutput>
    <br>
    </cfoutput>
    </td>
    <td width="33%" valign="top">
    <cfoutput query="GetSkill" group="category">
    <strong>#category#</strong><br>
    <cfoutput>
    <input type="checkbox" name="skill" value="#skill_id#"> #skill#<br>
    </cfoutput>
    <br>
    </cfoutput>
    </td>
    <td width="33%" valign="top">
    <cfoutput query="GetSkill" group="category">
    <strong>#category#</strong><br>
    <cfoutput>
    <input type="checkbox" name="skill" value="#skill_id#"> #skill#<br>
    </cfoutput>
    <br>
    </cfoutput>
    </td>

    jmoshier Guest

  2. #2

    Default Re: Split grouped query into columns

    Something like this will work
    <cfoutput query = "GetSkill" group = "category">
    #category#
    <cfset i=1>
    <table>
    <tr>
    <cfoutput>
    <td>#skill#</td>
    <cfif x mod 3 is 0></tr><tr>
    <cfset x = x + 1>
    closing tags.

    Originally posted by: jmoshier
    Hi,
    I am having a little problem splitting a grouped query into 3 columns. What I
    am trying to do is group a list of skills under their category and then display
    them in 3 columns.

    The two tables I am using is a
    skill table that contains: skill_id, skill and category_id
    category table that contains: cateogry_id, category

    Attached is my query code and the group output I have done so far.
    I obvisouly have not figured out where to put the startrows and maxrows so the
    three columns right now output the entire query three times. Any help would
    greatly be appreciated.
    Thanks
    jmoshier



    Dan Guest

  3. #3

    Default Re: Split grouped query into columns

    Dan,
    Thank you for the quick response. I am not sure I am understanding what you
    wrote. It looks like you are repeating the row three times with one cell in it.
    I would like one row with three cells containing the query results split.

    Please let me know if I am not making myself clear. I not quite sure how to
    explain it.
    Thanks for the help
    jmoshier

    jmoshier Guest

  4. #4

    Default Re: Split grouped query into columns

    It's a concept that I didn't test. How well do you understand the concept of
    using the group attribute in cfoutput?

    Originally posted by: jmoshier
    Dan,
    Thank you for the quick response. I am not sure I am understanding what you
    wrote. It looks like you are repeating the row three times with one cell in it.
    I would like one row with three cells containing the query results split.

    Please let me know if I am not making myself clear. I not quite sure how to
    explain it.
    Thanks for the help
    jmoshier



    Dan Guest

  5. #5

    Default Re: Split grouped query into columns

    I understand the purpose of using the group in the cfoutput is group data by a
    column in the database and only show it once.
    I.E. if I had data that returned this:
    Test Skill Category 1
    test Skill2 Category 1
    Test Skill3 Category 1
    test Skill 4 Category 2
    Test skill 5 Category 2
    When I use the group in the first output tag and group by category and then
    inside the nested cfoutput i would display the skills.
    I.E. I would see:
    Category 1
    Test Skill 1
    Test Skill 2
    Test Skill 3
    Category 2
    Test Skill 4
    Test Skill 5

    Is the grouping the reason I can't split the returned data into 3 equal
    columns? I was able to get the data to split correctly if I did not try to put
    the category on top of the group of skills.
    Thanks,
    jmoshier

    jmoshier Guest

  6. #6

    Default Re: Split grouped query into columns

    Untested code attached

    Regards.



    <table>
    <tr>
    <cfoutput query="GetSkill" group="category">
    <th>#category#</th>
    <td>
    <cfoutput>
    <input type="checkbox" name="skill" value="#skill_id#"> #skill#<br>
    </cfoutput>
    </td>
    </cfoutput>
    </tr>
    </table>

    PaulKD Guest

Similar Threads

  1. Replies: 7
    Last Post: April 6th, 05:47 PM
  2. Help with grouped query
    By Captain Special in forum Coldfusion Database Access
    Replies: 11
    Last Post: December 7th, 01:20 PM
  3. Multiple columns w/ grouped output
    By Explorer5 in forum Coldfusion - Advanced Techniques
    Replies: 1
    Last Post: July 7th, 01:44 AM
  4. Split text into two columns
    By Tim in forum PHP Development
    Replies: 2
    Last Post: July 20th, 07:01 AM
  5. Can we split content region into two columns?
    By Steve Doig in forum Macromedia Dreamweaver
    Replies: 1
    Last Post: July 8th, 06:21 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •