SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Dec 2001
    Location
    oslo
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    generate an xhtml table based upon a query

    hi

    I've found several examples on how to generate an xhtml table based upon a query & they all work perfectly but with a flaw that comes to the surface when the query returns 1, 3, 5 etc. results. In those cases the different code examples spit out the last tr without the final td.

    So my question is, does anybody know of a code example that shows how to I can build a table with two td's and still have the last td on the last tr present even if the query doesn't return a result that's dividable with 2?

    :water

  2. #2
    Chessplayer kleineme's Avatar
    Join Date
    Apr 2004
    Location
    Germany
    Posts
    608
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    why don't you take one of your examples and insert something like

    Code:
    if ($rownum % 2 != 0) {
      echo "<td>&nbsp;</td>;
    }
    before the output of the last </tr>?
    Never ascribe to malice,
    that which can be explained by incompetence.
    Your code should not look unmaintainable, just be that way.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •