Set table width

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • xo55ox

    Set table width

    Hi,

    I am new with php. I need to loop through some variables and place
    them in 3 columns. I couldn't align the header line and each result
    line. How do I make the table in uniform size in each column? And how
    do I wrap to new line if one of the variable is too long?
    Thanks in advance.
  • Tim Van Wassenhove

    #2
    Re: Set table width

    On 2003-12-08, xo55ox <xo55ox@hotmail .com> wrote:[color=blue]
    > Hi,
    >
    > I am new with php. I need to loop through some variables and place
    > them in 3 columns. I couldn't align the header line and each result
    > line. How do I make the table in uniform size in each column? And how
    > do I wrap to new line if one of the variable is too long?[/color]

    This is a HTML question meaning there are better for these questions.

    (the text in a column is auto-wrapped, so you don't need to break up the
    lines yourself)

    --
    verum ipsum factum

    Comment

    • Geoff Berrow

      #3
      Re: Set table width

      I noticed that Message-ID:
      <br1caq$26mcqg$ 3@ID-188825.news.uni-berlin.de> from Tim Van Wassenhove
      contained the following:
      [color=blue][color=green]
      >> I am new with php. I need to loop through some variables and place
      >> them in 3 columns. I couldn't align the header line and each result
      >> line. How do I make the table in uniform size in each column? And how
      >> do I wrap to new line if one of the variable is too long?[/color]
      >
      >This is a HTML question meaning there are better for these questions.[/color]

      But he needs to know how to write the php to give him three columns. I
      use a counter and use the modular operator to find the remainder when
      divided by three. Then a simple if statement is used to either finish
      the row or continue it.

      --
      Geoff Berrow (put thecat out to email)
      It's only Usenet, no one dies.
      My opinions, not the committee's, mine.
      Simple RFDs http://www.ckdog.co.uk/rfdmaker/

      Comment

      • Tim Van Wassenhove

        #4
        Re: Set table width

        On 2003-12-08, Geoff Berrow <blthecat@ckdog .co.uk> wrote:[color=blue]
        > I noticed that Message-ID:
        ><br1caq$26mcqg $3@ID-188825.news.uni-berlin.de> from Tim Van Wassenhove
        > contained the following:
        >[color=green][color=darkred]
        >>> I am new with php. I need to loop through some variables and place
        >>> them in 3 columns. I couldn't align the header line and each result
        >>> line. How do I make the table in uniform size in each column? And how
        >>> do I wrap to new line if one of the variable is too long?[/color]
        >>
        >>This is a HTML question meaning there are better for these questions.[/color]
        >
        > But he needs to know how to write the php to give him three columns. I
        > use a counter and use the modular operator to find the remainder when
        > divided by three. Then a simple if statement is used to either finish
        > the row or continue it.[/color]

        Sorry, i misunderstood the question.

        If he's going to fill the tables

        1 2 3
        4 5 6
        7 8 9

        then it's more efficient to use a counter, without modular operator.

        while (data available) {
        $counter = 0;
        echo "<tr>";
        while (data available && $counter < $columns) {
        echo "<td></td>";
        $counter++;
        }
        echo "</tr>";
        }

        Filling the tables as
        1 4 7
        2 5 8
        3 6 9

        He should first determine the number of rows ($rownum = #data / # columns wanted)
        and then make rows as
        <tr><td>$counte r+0*$rows</tid><td>$counte r+1*$rows</td><td>$cnt+2*$ row</td></tr>
        (Off course this can be optimised, as $rows is known.)

        --
        verum ipsum factum

        Comment

        Working...