Trying to display query results in 2 columns

I am trying modify someone elses existing code to display the
results of a query in 2 columns on a web page.
The result of the existing code can be seen
here
Below is the code that I am trying to modify
<table width="95%" border="0" align="center"
cellpadding="4" cellspacing="2">
<cfoutput query="News" startrow="#StartRow_News#"
maxrows="#MaxRows_News#">
<tr align="center" class="TEXTnormal">
<td nowrap class="TEXTnormal
style1">................................................................................. ...................................</td>
</tr>
<tr class="TEXTnormal">
<td><table width="100%" border="0" cellpadding="0"
cellspacing="0" class="TEXTnormal">
<tr>
<td><cfif News.ImageNameThumb gt 0>
<a href="news_view.cfm?recordID=#News.ID#"><img
src="uploadedimages/#News.ImageNameThumb#"
alt="#News.ImageCaption#" hspace="8" vspace="0" border="0"
align="left"></a>
<cfelse>
</cfif></td>
<td><a href="news_view.cfm?recordID=#News.ID#"
class="TEXThighlight">#News.Title#</a> -
#News.Day#.#News.Month#.#News.Year# <br>
#News.Summary#</td>
</tr>
</table></td>
</tr>
</cfoutput>
</table>
I have changed the above code to
<table width="95%" border="0" align="center"
cellpadding="4" cellspacing="2">
<cfset LoopEndRow = CEILING(#EndRow_News#/2)>
<cfloop
index = "row"
from = "#StartRow_News#"
to = "#LoopEndRow#"
step = "1">
<tr class="TEXTnormal">
<cfset breaker = 0>
<cfloop
index = "column"
from = "0"
to = "2"
step = "1">
<cfoutput query="News1" startrow="#StartRow_News#"
maxrows="#MaxRows_News#">
<td width="50%">
<table width="100%" border="0" cellpadding="0"
cellspacing="0" class="TEXTnormal">
<tr>
<td><cfif News1.ImageNameThumb gt 0>
<a href="news_view.cfm?recordID=#News1.ID#"><img
src="uploadedimages/#News1.ImageNameThumb#"
alt="#News1.ImageCaption#" hspace="8" vspace="0" border="0"
align="left"></a>
<cfelse>
</cfif></td>
<td><a href="news_view.cfm?recordID=#News1.ID#"
class="TEXThighlight">#News1.Title#</a> -
#News1.Day#.#News1.Month#.#News1.Year# <br>
#News1.Summary#</td>
</tr>
</table></td>
<cfset breaker = breaker+1>
<cfif breaker EQUAL 2>
<cfbreak>
</cfif>
</cfoutput>
</cfloop>
</tr>
</cfloop>
</table>
The results of this modified code can be see
Here
as you can see what I have done gives the correct number of
columns (2)
and the correct number of rows for the quantity of data (3)
however each row shows only the first 2 pieces of data
returned by the query
Can I modify the query output so that it returns pieces of
data off set by the amount of data already output?
if so how?

Right off the bat, you have 2 loops and I cant see why...
So what is happening, is the outer loop is going 3 times...
for 3 rows, then your inside loop is showing the first record, the
Breaker var is breakign out of this loop after one row is shown.
Then the main loop says do it again...
You don't need nested loops to accomplish this, I dont
understand why you would think of needing that...
Looking at your code, just get rid of the outer loop... there
is no need for it. You are already looping around the query object
in the inner loop, thats all you need...
Heres some psudeo code to help you out...
loop around query maximum of 6 rows
-- display data
-- if recordcount EQ 2 or recordcount EQ 4 then
----- </tr><tr> <!--- this will make the new
row --->
end loop

Similar Messages

  • How to display query result in seperated page.

    How to display query result in seperated page, if the results are very big (more than 5000 records) and there are so many concurrent users (about 500 - 1000 users).
    Are there any solutions or frameworks?
    Plese help me .........
    thanks,
    --bhasin

    Hi,
    How to display query result in seperated page?I think RowSet will be the better technology to use in this
    situation.For more information on this please visit http://developer.java.sun.com/developer/Books/JDBCTutorial/chapter5.html
    which explains in detail about RowSets.
    Hope this helps.
    Good Luck.
    Gayam.Srinivasa Reddy
    Developer Technical Support
    Sun Microsystems
    http://www.sun.com/developers/support/

  • How to display MySql query results in multiple columns?

    Hi, I know how to display PHP/MySq
    l query results in a single column, but I am really stuck at displa
    ying the results in multiple columns in DW CS4.
    Can anyone help me with a code example?. I am new to php/mysql. Thanks

    Are you asking how to pivot the results of the query? Do a search for horizontal looping. If that's not what you are asking, please provide more details.

  • 2.1 EA2 does not display query results, query works fine in sqlplus

    2.1 EA2/Windows XP 32-bit
    The following query does not show any results for Total(GB) and Free(GB) columns. The diskgroup name shows correctly.
    SELECT
    DG.name ,
    ROUND(SUM(DSK.TOTAL_MB)/1024,2) "Total (GB)",
    round(SUM(DSK.FREE_MB)/1024,2) "Free (GB)"
    FROM
    V$ASM_DISK DSK,
    V$ASM_DISKGROUP DG
    WHERE
    DSK.GROUP_NUMBER=DG.GROUP_NUMBER
    group by DG.name;
    The query works fine when run from SQL*Plus:
    SQL> SELECT
    2 DG.name ,
    3 ROUND(SUM(DSK.TOTAL_MB)/1024,2) "Total (GB)",
    4 round(SUM(DSK.FREE_MB)/1024,2) "Free (GB)"
    5 FROM
    6 V$ASM_DISK DSK,
    7 V$ASM_DISKGROUP DG
    8 WHERE
    9 DSK.GROUP_NUMBER=DG.GROUP_NUMBER
    10 GROUP BY DG.name;
    NAME Total (GB) Free (GB)
    DG1 707.98 162.32
    DG2 134.84 122.68
    SQL>
    This must be something unique to SQLDeveloper. I tested in 2.1 EA1 and 1.5.5.59.69 and the query does not show results for the Total (GB) and Free (GB) columns.

    I would like to update the problem. It seems like when SQLDeveloper is connected to ASM instance, it has trouble using the divide operator (/). For example, the following query works fine:
    SELECT
    name,
    TOTAL_MB
    FROM
    V$ASM_DISKGROUP;
    But if I try to divide the TOTAL_MB by any number, the column shows blank (the column is blank, not NULL). So, if I try to run the following query, the output will just display diskgroup names. The TOTAL_MB/1024 column shows blank.
    SELECT
    name,
    TOTAL_MB/1024
    FROM
    V$ASM_DISKGROUP;
    If I run the same query in SQL*Plus from the same desktop using the same TNS alias, it works just fine which tells me that it is a SQLDeveloper problem.
    When I am connected to a regular database, then the problem does not show up and SQLDeveloper is able to display the results even when I am using the divide operator (/).

  • How to display query result like this

    I got a query...gives list of names.
    i want to display
    11.  Peter
    12. Jessica
    32. Leo
    15. Jamie
    36. Edward
    how i get static number infront of my query result.
    static number is not in order.

    Amm85 wrote:
    I got a query...gives list of names.
    i want to display
    11.  Peter
    12. Jessica
    32. Leo
    15. Jamie
    36. Edward
    how i get static number infront of my query result.
    static number is not in order.
    You could use the function queryAddColumn to add the numbers as a separate column to the query.
    Let us suppose the name of the query is "myQuery". Then you could proceed as follows
    <!---Define your "static" list of numbers --->
    <cfset staticList = "11,12,32,15,36,13,23,14,33,16,44,31,17,34,18">
    <!--- Create an array from the static list. --->
    <cfset staticNrArray = ArrayNew(1)>
    <cfset staticNrArray = listToArray(staticList)>
    <!--- Add the array as a column to the query. --->
    <cfset nColumnNumber = QueryAddColumn(myQuery, "staticNr", "integer", staticNrArray)>
    <!--- Verify whether it works as expected--->
    <cfdump var="#myQuery#">
    The list I have given here has 15 numbers. This will naturally instruct ColdFusion to add a new column named staticNr, having 15 rows. You might like to know that the queryAddColumn function enables padding.
    Here is how it works. Suppose that the query originally had only 8 rows before you added the column(of 15 rows). Then, in the new query, ColdFusion would pad the last 7 rows of the other columns with null values. If the original query  had 20 rows instead, then Coldfusion would pad the last 5 rows corresponding to the staticNr-column with null values.

  • Display Query results in excel on the Web

    Hello,
    I am trying to display data from a query in excel on the web without creating an actual file. I know that I can create a CSV file using UTL_FILE and display it but I was hoping there was a way to do it without actually creating the file. I have a procedure that looks similar to
    PROCEDURE displayAsCSV is
    cursor STUD_CURS is
    select * from students;
    BEGIN
    for STUD_REC in STUD_CURS loop
    htp.print(' " '||STUD_REC.FIRST_NAME||' " , " '||STUD_REC.LAST_NAME||' " ');
    end loop;
    END;
    Does anyone know if it is possible to display these results in excel in the browser by altering the MIME types or something similar?
    Thanks

    Check Tom's owa_sylk utility together with the appropriate mime-type.

  • Problem Displaying Query Result

    I have been working through David's book 'Dreamweaver CS5 Training from the Source' and am attempting to adapt the tutorials for my own ideas.
    My problem, I believe is in displaying the results of a database query. I want to display to the user a list of group names they are associated with.
    The query looks like this:
    $id = "$identity->user_id"; //logged in user
    $sql = mysql_query("SELECT name
                                   FROM groups
                                   INNER JOIN user2group USING (group_id) // reference table contains user_id and group_id
                                   WHERE user_id = $id
                                   ORDER BY name")or trigger_error ( mysql_error ( ) );
    while($row = mysql_fetch_array($sql)){
              $groups = $row['name'];
    I attempt to display the results with:
    <?php echo "$groups"; ?>
    I have also tried:
    $sql = mysql_query("SELECT name
                                   FROM groups
                                   INNER JOIN user2group USING (group_id) // reference table contains user_id and group_id
                                   WHERE user_id = $id
                                   ORDER BY name")or trigger_error ( mysql_error ( ) );
    while($row = mysql_fetch_array($sql)){
              $groups = array();
              $groups[] = $row['name'];
    and display with:
    <?php echo implode('<br />', $groups); ?>
    In both scenarios I get only one record displayed. (there is more than one record). The records seem to be available to display because if I change the ORDER command I get a different result.
    Any help is much appreciated.
    Thank you

    Thank you so much for the explanation of the while loop it was extremely helpful. I was able to get my results to display correctly by including the echo statement in the while loop.
    I spent several hours trying to use the array_push command with no success. I did explore the link you provided, but found many of the examples people gave to be very complicated. I would really like to start working with this command, if you would be able to provide me with an example based on my query and I can see it working I can start varying it to some of the more complicated methods given in the link.
    Thank you again for your help.

  • Create SP that returns value and at the same time displays query result in output window

    I would like create an SP which will return the records from the table and also return value to my c# client application.
    For Example:
    Select * from employee returns all the query results in output window.
    Now I want to create an SP
    Create procedure Test
    As
    Declare @ret int,
    Select * from employee
    set @ret = Select count(*) from employee
    if @ret > 0
    return 1
    else
    return 0
    The above algo should return 1 0r 0 to c# client application and at the same time display all employees in sql query output window.
    Can u pls help in this regard.

    The above algo should return 1 0r 0 to c# client application and at the same time display all employees in sql query output window.
    Why?  and No!
    Why?  Your procedure generates a resultset of some number of rows.  You check the resultset for the presence of rows to determine if "anything is there".  You don't need a separate value to tell you this.  Note that it helps
    to post tsql that is syntactically correct.   While we're at it, if you just need to know that rows exist there is no need to count them since that does more work than required.  Simply test for existence using the appropriately-named function
    "exists".  E.g., if exists (select * from dbo.employee). 
    No!  A stored procedure does not display anything anywhere.  The application which executes the procedures is responsible for the consumption of the resultset; it chooses what to do and what to display. 
    Lastly, do not get into the lazy habit of using the asterisk in your tsql code.  That is not best practice.  Along with that, you should also get into the following best practice habits:
    schema-qualify your objects (i.e., dbo.employee)
    terminate every statement - it will eventually be required.

  • How to Display Query Results in a Max Width Formatted Way?

    Hi,
    I want to run a query to show the columns within headers to be formatted in a way that looks equal in width. I just want to get the max width for each column and display each item in a max width format in a query. Thanks.
    Ex.
    First Name Last Name City
    John Sumi New York
    Jay Heely Texas

    if you are spooling a file on sql*plus use the column formatting method.
    syntax:
      COL <column_name> FORMAT a<integer>example:
      COL emp_name FORMAT a40

  • PL/SQL to map query results to a column?

    Is there a programmatic way to map the query result to a value in a table?
    I have table A. There's a column with a carat-delimited string 0^0^1^ that I can parse with substr/instr functions. So, query that table/column for a 5th digit that sits between 5th and 6th ^ character.
    There's table B. It has a 'position' column and 'key' column. How do I let the table A know that when I query table A for 5th digit, it needs to map to table B's where position=5?
    thanks,

    Did you try to run those statements? Please do so next time.
    Also the creation of table C (or is it D) and E are missing.
    However, the tricky part is in deciphering table A to make up for the flawed design.
    I hope this piece of SQL is helpful for you, because you could join the outcome to your other tables:
    SQL> create table a
      2  ( visitor_id number(*,0),
      3  adate date,
      4  carat varchar2(4000 byte),
      5  ip_address varchar2(4000 byte),
      6  state varchar2(4000 byte),
      7  city varchar2(4000 byte),
      8  id number(*,0) not null enable,
      9  constraint "a" primary key (id)
    10  )
    11  /
    Tabel is aangemaakt.
    SQL> insert into A
      2  (VISITOR_ID,ADATE,CARAT,IP_ADDRESS,STATE,city,id) VALUES(194296532,TO_DATE('2007-06-26.00.01.46',''),'-1^1^2^0^3^85741^3^0^176^0^1
    ^-1^41^-1^-1^US^0^-1^2^0^1^^^^^^^','71.226.9.44','az','tucson',1);
    1 rij is aangemaakt.
    SQL> insert into A
      2  (VISITOR_ID,ADATE,CARAT,IP_ADDRESS,STATE,city,id) VALUES(37482918,TO_DATE('2007-06-26.00.01.46',''),'0^1^2^5^^78154^3^7^184^0^1^2^
    17^2^1^US^1^0^1^0^0^^^^^^^','70.163.196.111','tx','san antonio',2);
    1 rij is aangemaakt.
    SQL> select id
      2       , visitor_id
      3       , i position
      4       , c value
      5    from a
      6   model
      7         return updated rows
      8         partition by (id, visitor_id)
      9         dimension by (0 i)
    10         measures ('^' || carat || '^' c)
    11         rules
    12         ( c[for i from 1 to length(regexp_replace(c[0],'[^\^]'))-1 increment 1]
    13           = regexp_substr(c[0],'[^\^]+',1,cv(i))
    14         )
    15   order by id
    16       , position
    17  /
            ID VISITOR_ID   POSITION VALUE
             1  194296532          1 -1
             1  194296532          2 1
             1  194296532          3 2
             1  194296532          4 0
             1  194296532          5 3
             1  194296532          6 85741
             1  194296532          7 3
             1  194296532          8 0
             1  194296532          9 176
             1  194296532         10 0
             1  194296532         11 1
             1  194296532         12 -1
             1  194296532         13 41
             1  194296532         14 -1
             1  194296532         15 -1
             1  194296532         16 US
             1  194296532         17 0
             1  194296532         18 -1
             1  194296532         19 2
             1  194296532         20 0
             1  194296532         21 1
             1  194296532         22
             1  194296532         23
             1  194296532         24
             1  194296532         25
             1  194296532         26
             1  194296532         27
             1  194296532         28
             2   37482918          1 0
             2   37482918          2 1
             2   37482918          3 2
             2   37482918          4 5
             2   37482918          5 78154
             2   37482918          6 3
             2   37482918          7 7
             2   37482918          8 184
             2   37482918          9 0
             2   37482918         10 1
             2   37482918         11 2
             2   37482918         12 17
             2   37482918         13 2
             2   37482918         14 1
             2   37482918         15 US
             2   37482918         16 1
             2   37482918         17 0
             2   37482918         18 1
             2   37482918         19 0
             2   37482918         20 0
             2   37482918         21
             2   37482918         22
             2   37482918         23
             2   37482918         24
             2   37482918         25
             2   37482918         26
             2   37482918         27
             2   37482918         28
    56 rijen zijn geselecteerd.Regards,
    Rob.

  • Many to Many - display query result?

    Greetings
    In a help desk app, the manager can assingn more than one technician to a project.
    Whe he or she assigns a project, the tech ID & project ID are inserted in a junction table. This works fine.
    The description, assigned date & due date field are static- the resolution (textarea) needs to be added to as the project progesses, as well as hours spent by each tech.
    I am running into problems displaying what the technician sees on their "contol panel".
    When the tech views the details of an ongoing project, I am getting cartesian product results.
    The tech needs to add to the resolution (textarea),  view who else is working on the project, and how many hours each has contributed.
    The project display page query:
    SELECT DISTINCT project_ID, project_num, project_desc, project_res, assign_date, assign_time, due_date, complete_dte, complete_time, assigned,
    tech_1_hours, tech_2_hours, tech_3_hours, tech_4_hours, tech_ID, junc_tech_ID, junc_project_ID
    FROM main_projects, lookup_tech, junction_project_tech
    WHERE tech_ID = #Session.user_id#
    AND project_ID = #URL.project_ID#
    AND project_ID = junc_project_ID
    AND tech_ID = junc_tech_ID
    And the math;
    <cfset 'total' = (#tech_1_hours#+#tech_2_hours#+#tech_3_hours#+#tech_4_hours#)>
    The project display repeats itself for every technicain-
    Any help with this would be greatly apprecaited.
    24 month to retirement!
    Norman

    Hi,
    Will all Students have exactly two Teachers?
    If not picture your sample with two more Students.
    One having 1 Teacher
    One having N Teachers
    Think about N, what will it be? - How would you create a table with N columns?
    If you can't easily answer above, re-consider what you are trying.
    That said, it could still be done - even if all Students do not have exactly two Teachers - and is called Pivot a dynamic number of columns.
    Examples are in FAQ
    SQL and PL/SQL FAQ
    Still a bad idea, with or without known number of teachers
    Regards
    Peter

  • How to display query results in windows side by side in Access 2010

    In Access 2010 - when I open a query the result is desplayed in a tab.
    When I open a new query - a new tab is created - now in front of the other tab.
    I would like to see both queries at the same time.
    How is that done?

    Select File > Options.
    Click 'Current Database' in the navigation pane on the left.
    Under 'Document window options', select 'Overlapping Windows'.
    Click OK, then close and reopen the database.
    Regards, Hans Vogelaar (http://www.eileenslounge.com)

  • Displaying Query Results as Hyperlinks using PHP

    I have a table returning a query, one of the fields returns
    an email address. I want to link this so the admin user can click
    on it and have his or her email client open to that address. The
    address does not go in the DB as a link. Here is the code:
    .$row[4]. being the returned value, I tried adding a <a
    href='mailto:'> the value</a> several different ways but
    it just breaks the page. any insight?
    Thanks,
    Steve

    steevo2 wrote:
    > Thanks, it didn't work , but got me going in the right
    direction. double
    > quotes will not work inside any tag
    Complete nonsense. The reason it didn't work is because I
    missed out a
    single quote. The correct code is this:
    echo '<td width="175"><a
    href="mailto:'.$row[4].'">'.$row[4].'</a></td>';
    Note the extra single quote after the first $row[4].
    > Double quotes do work outside of tags, I have them
    surrounding the rest of my
    > table tag elements, but single quotes work in that
    respect as well.Thanks for
    > responding, plan on getting your books soon.
    If you get one of my books, you'll find a detailed discussion
    of the
    difference between single and double quotes, and how to mix
    them. It's a
    subject that confuses many beginners. And, as my mistake
    shows, it
    catches out more experienced people too. The difference
    between a
    beginner and a more experienced developer is that the latter
    can spot
    more quickly where the error lies.
    > I must confess, pulling this off
    > in CF is much easier. But hey, open source is free. I
    use CF at work and PHP at
    > home.
    Personally, I don't find CF easier, but I'm sure it's more a
    question of
    what you're used to, rather than one being "easier" than the
    other.
    David Powers, Adobe Community Expert
    Author, "The Essential Guide to Dreamweaver CS3" (friends of
    ED)
    Author, "PHP Solutions" (friends of ED)
    http://foundationphp.com/

  • Trying to display a result set in a jsp page

    While trying to do that, i get this exception
    org.apache.jasper.JasperException: An exception occurred processing JSP page /tablasUF.jsp at line 17
    14:
    15: Connection con = src.Connect.connectMe();
    16:
    17: Statement statement = con.createStatement() ;
    18: ResultSet resultset =
    19: statement.executeQuery("select * from UF_CUSTOMER");
    20:
    Stacktrace:
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    root cause
    java.lang.NullPointerException
    org.apache.jsp.tablasUF_jsp._jspService(tablasUF_jsp.java:68)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

    River_Plate wrote:
    root cause
    java.lang.NullPointerException
    org.apache.jsp.tablasUF_jsp._jspService(tablasUF_jsp.java:68)Do you understand anyway when a NullPointerException would be thrown? Those kind of RuntimeExceptions are basic Java knowledge.
    If an object is null while you want to access it, then a NPE would be thrown. Check the line of the cause which objects could be null and fix it accordingly.

  • Display Query Output - Rows as Columns

    Hi ,
    I am fetching data as follows.
    ITEM CODE, DESCRIPTION, UOM, PRICELISTNAME, PRICELISTVALUE
    Item can exists in more than one price list.
    I want get the output as follows
    ITEM CODE, DESCRIPTION, UOM, PLIST1 PLIST2
    X X X PLIST VAL1 PLISTVAL2
    Y Y Y PLISTVAL2
    Item X exists in PLIST1 and PLIST2, but, item Y exists in only Plist2.
    Can this be possible. Please let me know, if some one as solution for this requirement.
    Regards/Prasanth

    ITEM CODE...DESCRIPTION....UOM.......PLIST1.......PLIST2
    X..................X.........................X.............PLVAL1.....PLVAL2
    Y.................Y.........................Y..............................PLVAL2

Maybe you are looking for

  • Playlists Missing After Install New Hard Drive and Upgrade to Win 7

    My computer needed a new hard drive and I upgraded from Win Vista Home Premium to Windows 7 Home Premium. I am trying to get my Playlists back for my iTunes in my "Administrator" user account, after reinstalling iTunes and putting my music libraries

  • Error While Running KE5T

    Short text     Error in module RSQL of the database interface. What happened?     Error in the ABAP Application Program     The current ABAP program "GP$GLX$GLPCT" had to be terminated because it has     come across a statement that unfortunately can

  • FM TRANSACTION_BEGIN

    Hello, Can you please let me know what is the main purpose/use of this FM? I can't find much from the help documentation. Can we use it along with any of the BAPI's? Thanks.

  • Adjusting background image?

    I'm pretty new to the creating of homepages, so this might be a rather basic problem, but anyhow here's my question: I've created my own background image in Photoshop and imported it to Dreamweaver as a background image with the script: background-im

  • Total Number of Songs

    well i have only just noticed that when my iPod is plugged into my laptop and playing through iTunes i have 3607 songs, i have added 2 albums today ejected my iPod etc and noticed my total number of songs is still on 3495 when i look through all my a