displaying query in 2 columns

Ask a Question related to Coldfusion - Getting Started, Design and Development.

  1. #1

    Default displaying query in 2 columns

    Hi Guys, need your help on this please, I am trying to get the result of my
    query splited in 2 columns, where in the first column will have my first half
    and the second column will have the other half, can you guys help? I need that
    in orther the first column the first amount of data and the second the rest of
    the data, really apreciated that. Thank you Titano Cruz

    simprini Guest

  2. Similar Questions and Discussions

    1. displaying multiple columns in <cfselect>
      ok, I have a database that house a table called model. The model contains a manufacturer foreign key and 3 other fileds for that table. I want...
    2. Hiding/Displaying... Columns....
      How to hide/display the datagrid colums at run time? ..Net 1.1. Thanks, Smith
    3. Specify Query Columns from From
      I want to create a form where a user can select from a drop down box which query colums they want to select and in what order. The form will be...
    4. displaying images in multiple columns
      hi, i want to display in my form pictures(the url is taken from a database), like this: pic1 pic2 pic3 pic4 pic5 pic6 .... i ve...
    5. Displaying fields(columns) in MS Access
      Good day to everyone. I have found using various connection types my table display comes up differently. If I use an OLEDB type connections my...
  3. #2

    Default displaying query in 2 columns

    Hi Guys, need your help on this please, I am trying to get the result of my
    query splited in 2 columns, where in the first column will have my first half
    and the second column will have the other half, can you guys help? I need that
    in orther the first column the first amount of data and the second the rest of
    the data, really apreciated that. Thank you Titano Cruz

    simprini Guest

  4. #3

    Default displaying query in 2 columns

    Hi Guys, need your help on this please, I am trying to get the result of my
    query splited in 2 columns, where in the first column will have my first half
    and the second column will have the other half, can you guys help? I need that
    in orther the first column the first amount of data and the second the rest of
    the data, really apreciated that. Thank you Titano Cruz

    simprini Guest

  5. #4

    Default Re: displaying query in 2 columns

    Hi Titano

    Here is one way, have a table and loop through the first half of the query for
    the first column of the table and the 2nd half of the query for the second
    table column.

    Can probably make the code a bit better but thats the idea.

    HTH

    Zoe

    <CFSET halfWay = ceiling(queryName.RecordCount / 2) - 1>
    <TABLE>
    <TR><TD>
    <CFLOOP QUERY="queryName" STARTROW="1" ENDROW="#halfWay#">
    #output#<BR>
    </CFLOOP>
    </TD>
    <TD>
    <CFLOOP QUERY="queryName" STARTROW="#halfWay#"
    ENRROW="#queryName.RecordCount#">
    #output#<BR>
    </CFLOOP>
    </TD></TR>
    </TABLE>

    zoeski80 Guest

  6. #5

    Default Re: displaying query in 2 columns

    I do not believe that you can loop content from one column to another like
    on a printed page however you could achieve it will a little scripting and
    assuming that your layout is CSS based. This is what I would do

    1) Work out the number of line in the query and set it to a value
    <cfset TotalLine = QueryName.RecountCount>

    2) Then find the middle
    <cfset HalfWay = TotalLine/2>

    3) Now write the first column
    <div id="leftcol">
    <cfoutput query="QueryName">
    <CFIF QueryName.CurrentRow LE HalfWay>
    #Fieldname#
    </cfif>
    </cfoutput>
    </div>

    4) Finally write the second column
    <div id="rightcol">
    <cfoutput query="QueryName">
    <CFIF QueryName.CurrentRow GT HalfWay>
    #Fieldname#
    </cfif>
    </cfoutput>
    </div>

    --
    Regards

    Paul Whitham
    Macromedia Certified Professional for Dreamweaver MX2004
    Valleybiz Internet Design
    [url]www.valleybiz.net[/url]

    Team Macromedia Volunteer for Ultradev/Dreamweaver MX
    [url]www.macromedia.com/support/forums/team_macromedia[/url]

    "simprini" <webforumsuser@macromedia.com> wrote in message
    news:d0l7d0$klm$1@forums.macromedia.com...
    > Hi Guys, need your help on this please, I am trying to get the result of
    my
    > query splited in 2 columns, where in the first column will have my first
    half
    > and the second column will have the other half, can you guys help? I need
    that
    > in orther the first column the first amount of data and the second the
    rest of
    > the data, really apreciated that. Thank you Titano Cruz
    >

    Paul Whitham TMM Guest

  7. #6

    Default Re: displaying query in 2 columns

    I think this is what you need:

    <cfquery datasource="#DSN#" name="Q">
    <!--- Your SQL statement goes here --->
    </cfquery>

    <cfset recordcountHalf = Q.recordcount \ 2>

    <table>
    <tr>

    <td>
    <cfoutput query="Q" startrow="1" maxrows="#variables.recordcountHalf#">
    <!--- Display data --->
    </cfoutput>
    </td>

    <td>
    <cfoutput query="Q" startrow="#val(variables.recordcountHalf+1)#">
    <!--- Display data --->
    </cfoutput>
    </td>

    </tr>
    </table>

    externalError Guest

  8. #7

    Default Re: displaying query in 2 columns

    here is a little more complex example. it will allow you to display it in a
    table. just replace query with your query name and columnname with the column.
    <cfset foo = Int(query.recordcount / 2) + query.recordcount mod 2 /> <table>
    <cfloop from='1' to='#foo#' index='x'> <tr>
    <td>#query['columnname'][x]#</td> <cfif foo + x lte query.recordcount>
    <td>#query['columnname'][foo+x]#</td> <cfelse> <td>&amp;nbsp;</td>
    </cfif> </tr> </cfloop> </table> hope that helps

    pdlnhrd Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139