printing a long HTML table

Discussion in 'HTML' started by Larry, Sep 14, 2005.

  1. Larry

    Larry Guest

    I have a CGI program that generates a fairly long HTML table in
    response to a query. How do I make it so that the user can print the
    table from their browser and have the column headings show up on the
    top of each page? I know about the "page-break-after" style tag, but I
    have no way to know when to output it. Another option I've considered
    is something like Crystal Reports, but that's expensive, complex, and
    way more than what I need.
    Larry, Sep 14, 2005
    #1
    1. Advertising

  2. Larry

    mbstevens Guest

    Larry wrote:
    > I have a CGI program that generates a fairly long HTML table in
    > response to a query. How do I make it so that the user can print the
    > table from their browser and have the column headings show up on the
    > top of each page? I know about the "page-break-after" style tag, but I
    > have no way to know when to output it. Another option I've considered
    > is something like Crystal Reports, but that's expensive, complex, and
    > way more than what I need.
    >


    Since you are generating the pages with a programming language,
    couldn't you come up with some kind of heuristic test?

    if (position >= MAXROW)
    generate break
    if ((row contains x) and (position >= MINROW)
    generate break
    if ...
    if ...
    if ....

    Should be easy enough to do in most CGI scripting languages.
    --
    mbstevens
    http://www.mbstevens.com
    mbstevens, Sep 14, 2005
    #2
    1. Advertising

  3. Larry

    Oli Filth Guest

    mbstevens said the following on 14/09/2005 16:15:
    > Larry wrote:
    >
    >> I have a CGI program that generates a fairly long HTML table in
    >> response to a query. How do I make it so that the user can print the
    >> table from their browser and have the column headings show up on the
    >> top of each page? I know about the "page-break-after" style tag, but I
    >> have no way to know when to output it. Another option I've considered
    >> is something like Crystal Reports, but that's expensive, complex, and
    >> way more than what I need.
    >>

    >
    > Since you are generating the pages with a programming language, couldn't
    > you come up with some kind of heuristic test?
    >
    > if (position >= MAXROW)
    > generate break
    > if ((row contains x) and (position >= MINROW)
    > generate break
    > if ...
    > if ...
    > if ....
    >
    > Should be easy enough to do in most CGI scripting languages.


    But that can't take account of page size, print margins, browser text
    size, ...

    --
    Oli
    Oli Filth, Sep 14, 2005
    #3
  4. Larry

    Dima Gofman Guest

    > Larry wrote:
    >
    >> I have a CGI program that generates a fairly long HTML table in
    >> response to a query. How do I make it so that the user can print the
    >> table from their browser and have the column headings show up on the
    >> top of each page? I know about the "page-break-after" style tag, but I
    >> have no way to know when to output it. Another option I've considered
    >> is something like Crystal Reports, but that's expensive, complex, and
    >> way more than what I need.
    >>


    Simple! In FireFox it's enough to simply use <thead> and <th> tags and
    to get the same effect in IE all you need is a bit of CSS. Like so:

    <html><head><title></title>
    <style type='text/css'>
    thead{display:table-header-group}
    </style>
    </head><body>
    <table>
    <thead>
    <tr>
    <th>col1</th>
    <th>col2</th>
    <th>col3</th>
    <th>col4</th>
    <th>col5</th>
    </tr>
    </thead>
    <tbody>
    <tr>
    <td>x1</td>
    <td>x2</td>
    <td>x3</td>
    <td>x4</td>
    <td>x5</td>
    </tr>
    ..........alot of rows...........
    </tbody>
    </table></body></html>


    -
    Dima Gofman
    Dima Gofman, Sep 14, 2005
    #4
  5. Larry

    mbstevens Guest

    Oli Filth wrote:
    > mbstevens said the following on 14/09/2005 16:15:
    >
    >> Larry wrote:
    >>
    >>> I have a CGI program that generates a fairly long HTML table in
    >>> response to a query. How do I make it so that the user can print the
    >>> table from their browser and have the column headings show up on the
    >>> top of each page? I know about the "page-break-after" style tag, but I
    >>> have no way to know when to output it. Another option I've considered
    >>> is something like Crystal Reports, but that's expensive, complex, and
    >>> way more than what I need.
    >>>

    >>
    >> Since you are generating the pages with a programming language,
    >> couldn't you come up with some kind of heuristic test?
    >>
    >> if (position >= MAXROW)
    >> generate break
    >> if ((row contains x) and (position >= MINROW)
    >> generate break
    >> if ...
    >> if ...
    >> if ....
    >>
    >> Should be easy enough to do in most CGI scripting languages.

    >
    >
    > But that can't take account of page size, print margins, browser text
    > size, ...
    >



    Browser text size need not affect the printout.
    For page size and print margins, you would could
    1) give the visitor a choice of several common formats available
    in different parts of the world;
    2) let the visitor fill out a form describing her page size,
    then set MAXROW, MINROW, margins, styles, etc. from that;
    mbstevens, Sep 14, 2005
    #5
  6. Larry a écrit :
    > I have a CGI program that generates a fairly long HTML table in
    > response to a query. How do I make it so that the user can print the
    > table from their browser and have the column headings show up on the
    > top of each page? I know about the "page-break-after" style tag, but I
    > have no way to know when to output it. Another option I've considered
    > is something like Crystal Reports, but that's expensive, complex, and
    > way more than what I need.
    >


    Use <thead> accordingly.
    "When long tables are printed, the table head and foot information may
    be repeated on each page that contains table data."
    http://www.w3.org/TR/html401/struct/tables.html#h-11.2.3

    http://www.w3.org/WAI/UA/TS/html401/cp1001/1001-THEAD-TBODY-TFOOT-OVERFLOW.html

    Gérard
    --
    remove blah to email me
    =?ISO-8859-1?Q?G=E9rard_Talbot?=, Sep 14, 2005
    #6
  7. Dima Gofman a écrit :

    > Simple! In FireFox it's enough to simply use <thead> and <th> tags and
    > to get the same effect in IE all you need is a bit of CSS. Like so:
    >
    > <html><head><title></title>
    > <style type='text/css'>
    > thead{display:table-header-group}


    thead by default is declared as display: table-header-group in CSS 2.x
    compliant browsers. So there is really no need to redefine it again. In
    other browsers, like MSIE 6, declaring thead{display:table-header-group}
    won't achieve anything anyway since display:table-header-group is not
    supported.

    Gérard
    --
    remove blah to email me
    =?ISO-8859-1?Q?G=E9rard_Talbot?=, Sep 14, 2005
    #7
  8. Larry

    Larry Guest

    Dima Gofman wrote:
    > > Larry wrote:
    > >
    > >> I have a CGI program that generates a fairly long HTML table in
    > >> response to a query. How do I make it so that the user can print the
    > >> table from their browser and have the column headings show up on the
    > >> top of each page? I know about the "page-break-after" style tag, but I
    > >> have no way to know when to output it. Another option I've considered
    > >> is something like Crystal Reports, but that's expensive, complex, and
    > >> way more than what I need.
    > >>

    >
    > Simple! In FireFox it's enough to simply use <thead> and <th> tags and
    > to get the same effect in IE all you need is a bit of CSS. Like so:
    >
    > <html><head><title></title>
    > <style type='text/css'>
    > thead{display:table-header-group}
    > </style>
    > </head><body>


    ....

    Thanks! I'll try that!
    Larry, Sep 15, 2005
    #8
  9. Larry

    Dima Gofman Guest

    Gérard Talbot wrote:

    > declaring thead{display:table-header-group}
    > won't achieve anything anyway since display:table-header-group is not
    > supported.


    It is in MSIE6, IE6 doesn't display <thead> at the top of every page by
    default, thead{display:table-header-group} forces it to do this and it
    doesn't hurt firefox. Try it out. Unfortunately i don't have Opera
    handy to see what works/doesn't work there

    -
    Dima Gofman
    Dima Gofman, Sep 15, 2005
    #9
  10. Gérard Talbot wrote:
    > thead by default is declared as display: table-header-group in CSS 2.x
    > compliant browsers.


    CSS does not require any particular default rendering of HTML elements.
    Leif K-Brooks, Sep 16, 2005
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. George Marsaglia

    Assigning unsigned long to unsigned long long

    George Marsaglia, Jul 8, 2003, in forum: C Programming
    Replies:
    1
    Views:
    658
    Eric Sosman
    Jul 8, 2003
  2. Daniel Rudy

    unsigned long long int to long double

    Daniel Rudy, Sep 19, 2005, in forum: C Programming
    Replies:
    5
    Views:
    1,176
    Peter Shaggy Haywood
    Sep 20, 2005
  3. Mathieu Dutour

    long long and long

    Mathieu Dutour, Jul 17, 2007, in forum: C Programming
    Replies:
    4
    Views:
    459
    santosh
    Jul 24, 2007
  4. Bart C

    Use of Long and Long Long

    Bart C, Jan 9, 2008, in forum: C Programming
    Replies:
    27
    Views:
    780
    Peter Nilsson
    Jan 15, 2008
  5. veryhotsausage
    Replies:
    1
    Views:
    1,776
    veryhotsausage
    Jul 4, 2008
Loading...

Share This Page