#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    64
    Rep Power
    2

    Trouble with table elements


    I'm not quite sure what I'm missing, but for some reason the last two close tags "</td>, </tr>" are not closing the second column and first row respectively.

    Any help would be greatly appreciated.

    Here's the PHP:

    PHP Code:
    echo '   <tr width="500">
            <td width="200"> <img src="'
    .$item[2].'"/></td>
        <td width="300">
            <tr>
                <td width="150">Picture Name</td><td width="150">'
    .$item[1].'</td>
            </tr>
            <tr>
                <td width="150">Tag</td><td width="150">'
    .$item[4].'</td>
            </tr>
            <tr>
                <td width="150">Category</td><td width="150">'
    .$item[3].'</td>
            </tr>
            <tr>
                <td width="150">ID</td><td width="150">'
    .$item[0].'</td>
            </tr>
            <tr>
                <td width="150">User ID</td><td width="150">'
    .$item[5].'</td>
            </tr>
            <tr>
                <td width="150">IP</td><td width="150">'
    .$item[6].'</td>
            </tr>
            <tr>
                <td width="150">Timestamp</td><td width="150">'
    .$item[7].'</td>
            </tr>
        </td>
    </tr>'

    Here's the html output from the browser source:

    Code:
       <tr width="500">
            <td width="200"> <img src="pending/test.jpg"/></td>
        <td width="300">
            <tr>
                <td width="150">Picture Name</td><td width="150">2.gif</td>
            </tr>
            <tr>
                <td width="150">Tag</td><td width="150">random funny picture</td>
            </tr>
            <tr>
                <td width="150">Category</td><td width="150">Random</td>
            </tr>
            <tr>
                <td width="150">ID</td><td width="150">2</td>
            </tr>
            <tr>
                <td width="150">User ID</td><td width="150">0</td>
            </tr>
            <tr>
                <td width="150">IP</td><td width="150">127.0.0.1</td>
            </tr>
            <tr>
                <td width="150">Timestamp</td><td width="150">2012-12-25 02:10:29</td>
            </tr>
        </td>
    </tr>
  2. #2
  3. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,317
    Rep Power
    7170
    You can't put a <tr> tag directly inside a <td> tag.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    64
    Rep Power
    2
    Originally Posted by E-Oreo
    You can't put a <tr> tag directly inside a <td> tag.
    I'm trying to create an output that should display a total of two columns within the first <tr> tag. The column on the left should go from the top to bottom of its parent row, and column to the right of that should hold seven additional rows.

    If I can't put a <tr> tag in a <td> how do you create additional rows inside a particular column?
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2009
    Posts
    676
    Rep Power
    7
    Code:
    <table>
      <tr>
        <td>Row 1 Col 1</td>
        <td>Row 1 Col 2</td>
      </tr>
      <tr>
        <td>Row 2 Col 1</td>
        <td>Row 2 Col 2</td>
      </tr>
      <tr>
        <td>Row 3 Col 1</td>
        <td>Row 3 Col 2</td>
      </tr>
      <tr>
        <td>Row 4 Col 1</td>
        <td>Row 4 Col 2</td>
      </tr>
      <tr>
        <td>Row 5 Col 1</td>
        <td>Row 5 Col 2</td>
      </tr>
      <tr>
        <td>Row 6 Col 1</td>
        <td>Row 6 Col 2</td>
      </tr>
      <tr>
        <td>Row 7 Col 1</td>
        <td>
          <table>
            <tr>
              <td>Another table</td>
            </tr>
          </table>
        </td>
      </tr>
    </table>
    Each <td> tag defines a column. You may also use colspan attribute in one. Usually as a header. This will make the cell span 2 columns.

    Edit: Another note... You CAN build tables within tables. Keep in mind inner tables must remain within the cell they started.

    Comments on this post

    • nbasso713 agrees
    Last edited by Triple_Nothing; December 26th, 2012 at 08:33 PM.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    64
    Rep Power
    2
    Originally Posted by Triple_Nothing
    Each <td> tag defines a column. You may also use colspan attribute in one. Usually as a header. This will make the cell span 2 columns.

    Edit: Another note... You CAN build tables within tables. Keep in mind inner tables must remain within the cell they started.
    Thanks that did it, I mixed up using that row with creating a second table.
  10. #6
  11. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,317
    Rep Power
    7170
    You can also use the colspan and rowspan attributes of the <td> tag.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

IMN logo majestic logo threadwatch logo seochat tools logo