displaying output - how?

Ask a Question related to Macromedia ColdFusion, Design and Development.

  1. #1

    Default displaying output - how?

    I'm sure this isn't too complicated, but I'm confused as to how to do it. I am
    outputing a list of books - each book title has a few (up to about 3) related
    web sites. I want to display the information something like this -

    title1 - date, author, related website 1, related website 2, etc.
    title2 - date, author, related website 1, related website2, etc.

    I've got a query that gets the information I need, but I can't seem to output
    it correctly. I keep getting something like this:


    title1 - date, author, related website 1,
    title1 - date, author, related website 2,
    title1 - date, author, related website 3,
    title2 - date, author, related website 1,
    title2 - date, author, related website 2,
    title3 - date, author, related website 1, etc.

    I can't seem to get it to show each book once, along with its related web
    sites and I'm not sure if the problem is with my initial query, or with the
    output. The query is as follows:

    <cfquery name="getbooks" datasource="books" dbtype="ODBC">
    SELECT bookclubbooks.clubbook_id, bookclubbooks.clubbook_title,
    bookclubbooks.clubbook_authorlname, bookclubbooks.clubbook_authorfname,
    bookclubbooks.clubbook_isbn, bookclubbooks.clubbook_checkisbn,
    bookclubbooks.bookclub_id, bookclubbooks.clubbook_schedule,
    clubbookslinks.clubbooklink_id, clubbookslinks.clubbook_id,
    clubbookslinks.clubbook_linktitle, clubbookslinks.clubbook_linkurl
    FROM bookclubbooks, clubbookslinks
    WHERE bookclubbooks.clubbook_id = clubbookslinks.clubbook_id
    AND bookclub_id = #url.bookclub_id#
    ORDER BY clubbook_schedule
    </cfquery>

    And here's the relevant output code -

    <cfoutput query="getbooks">
    <td align="center" valign="top"><img src="..."/></td>
    <td align="left" valign="top">#DateFormat(clubbook_schedule, 'mmmm dd,
    yyyy')#<br />
    <a href="...">#clubbook_title#</a></span>
    by #clubbook_authorfname#&nbsp;#clubbook_authorlname# <br />
    <cfif #clubbook_linktitle# IS NOT "">Related Web Sites:
    <ul><li><a
    href="clubbook_linkurl">#clubbook_linktitle#</a></li></ul></cfif></td>
    </tr>
    </table>
    </cfoutput>

    I know I need some sort of loop somehow to get it to display all the links for
    one title without repeating the title, but I'm confused as to how to do that.
    Any suggestions would be greatly appreciated.

    Thanks for reading this far.
    Michelle

    Micheller Guest

  2. Similar Questions and Discussions

    1. Displaying JobTicket colorant data in Output Preview dialog.
      Hi, my task is to create plug-in which extends functionality of Output Preview dialog. It should display actual state of all Separations and Inks...
    2. displaying a jpg
      I have a upload file page that contains a form which submits to a page that inserts the file path into an access database and the file into a photo...
    3. Carriage returns/output not displayed in output.asp
      PLEASE DON'T MULTIPOST. PLEASE DON'T POST ATTACHMENTS. PLEASE DON'T DOUBLE-POST. Ray at work
    4. Displaying Resultset output in Excel format in a NEW window
      Hi, I have written an ASP script that connects to a database and runs a stored procedure and displays the results in text format ...using the...
    5. #25152 [Opn->Bgs]: output buffering functions don't catch "virtual" output
      ID: 25152 Updated by: iliaa@php.net Reported By: msarsale at buenosaires dot gov dot ar -Status: Open +Status:...
  3. #2

    Default Re: displaying output - how?

    I think something like this:

    <table>
    <cfoutput query="getbooks" group="Title">
    <tr>
    <td>#title#</td>
    <td>#author#</td>
    <td>#date#</td>

    <cfoutput>
    <td>#website#</td>
    </tr>
    </cfoutput>
    </cfoutput>
    </table>

    Hope this helps

    GeorgeWS Guest

  4. #3

    Default Re: displaying output - how?

    Try using the "group" property in the cfoutput tag. This is going to involve
    nesting cfoutput tags. See the code below.

    <cfoutput query="getbooks"group="clubbook_id" >
    <td align="center" valign="top"><img src="..."/></td>
    <td align="left" valign="top">#DateFormat(clubbook_schedule, 'mmmm dd,
    yyyy')#<br />
    <a href="...">#clubbook_title#</a></span>
    by #clubbook_authorfname#&nbsp;#clubbook_authorlname# <br />
    <cfif #clubbook_linktitle# IS NOT "">Related Web Sites:
    <ul><cfoutput><li><a
    href="clubbook_linkurl">#clubbook_linktitle#</a></li></cfoutput></ul></cfif></td
    >
    </tr>
    </table>
    </cfoutput>

    patb96 Guest

  5. #4

    Default Re: displaying output - how?

    Thanks so much for your help! I feel stupid for not remembering about the group
    attribute. OK, the problem I'm having now is (I think) with my CFIF statement.
    I want the book graphic, title, author name and date to show regardless. If
    there are related links for a particular book, than I want to also display the
    header "related books" with the bulleted list of links. As it is right now, if
    there are no related links, than nothing shows at all (for that particular
    book). I'm thinking this may mean I can't use the group attribute after all?

    Here's the output code I have now:

    <cfoutput query="getbooks" group="clubbook_title">
    <table>
    <tr>
    <td align="center" valign="top"><img src="..." alt="book jacket for
    #clubbook_title#" width="62" height="94" align="left"/></td>
    <td align="left" valign="top">#DateFormat(clubbook_schedule, 'mmmm dd,
    yyyy')#<br />
    <a href="...">#clubbook_title#</a></span>
    by #clubbook_authorfname#&nbsp;#clubbook_authorlname# <br />
    <cfif #clubbook_linktitle# IS NOT "">Related Web Sites:<br />
    <ul> <cfoutput><li><a
    href="clubbook_linkurl">#clubbook_linktitle#</a></li></cfoutput></ul></cfif></td
    >
    </tr>
    </table>
    </cfoutput>

    Thanks again.

    Micheller Guest

  6. #5

    Default Re: displaying output - how?

    You can do thus but the problem is your SQL statement! I assuming that you are
    using an inner join to get the books and the related links. That only returns
    records that exist in both tables. So you need to use a Left or Right join
    (whichever one is relevant) instead. That will return all the results from the
    Left or Right table repectively regardless of results in the other!

    Post your query and I can help more!

    Stressed_Simon Guest

  7. #6

    Default Re: displaying output - how?

    Oh I see your query hang on!
    Stressed_Simon Guest

  8. #7

    Default Re: displaying output - how?

    Try:-

    <cfquery name="getbooks" datasource="books" dbtype="ODBC">
    SELECT bookclubbooks.clubbook_id, bookclubbooks.clubbook_title,
    bookclubbooks.clubbook_authorlname, bookclubbooks.clubbook_authorfname,
    bookclubbooks.clubbook_isbn, bookclubbooks.clubbook_checkisbn,
    bookclubbooks.bookclub_id, bookclubbooks.clubbook_schedule,
    clubbookslinks.clubbooklink_id, clubbookslinks.clubbook_id,
    clubbookslinks.clubbook_linktitle, clubbookslinks.clubbook_linkurl
    FROM bookclubbooks
    LEFT JOIN clubbookslinks ON bookclubbooks.clubbook_id =
    clubbookslinks.clubbook_id
    WHERE bookclub_id = #url.bookclub_id#
    ORDER BY clubbook_schedule
    </cfquery>

    Stressed_Simon Guest

  9. #8

    Default Re: displaying output - how?

    It works! I've never been really clear about left and right inner joins, but now I think I'm beginning to understand.

    Thanks for the help and the code.
    Micheller Guest

  10. #9

    Default Re: displaying output - how?

    Glad to help. I cannot stress any more strongly that getting to grips with SQL
    is paramount to building scaleable applications. The database is very powerful
    and is where you should do as much work as possible. You will be glad you did
    in the long run.

    Stressed_Simon 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