SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict AbelaJohnB's Avatar
    Join Date
    Oct 2001
    Location
    Eureka, CA. USA
    Posts
    250
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Dynamic Tables, Take 2

    Hello.

    freddydoesphp, posted the following code sometime back:



    PHP Code:
    <table border=1><tr>
    <?php
    $count 
    1;
    $numcols 3;
    for(
    $i=0;$i<33;$i++) {
        print 
    "<td>$i</td>";
        print (
    is_int($count/$numcols)) ? "</tr><tr>" "";
        
    $count++;
        }
    ?>
    </tr></table>


    Here is my problem with this...


    Let's say, rather then 33 you had 32.

    This is going to create invalid HTML4 compliant code, as it does not finalize the final <TD></TD>, instead it just skips it.


    I've been trying to figure out how to correct this, but thing is working.

    Anybody have a solution to this?

    It really does need to have:

    <TD>&nbsp;</TD>

    in the last row, to work correctly.

    Thanks.
    John B. Abela
    www.JohnAbela.Com

  2. #2
    Custom User Title v1.0 FireFly's Avatar
    Join Date
    Aug 2001
    Posts
    363
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just want it to print empty cells to make the table complete?
    PHP Code:
    <table border=1><tr>
    <?php
    $row 
    1;
    $count 1;
    $numcols 3;
    for(
    $i=0;$i<32;$i++) {
        print 
    "<td>$i</td>";
        if (
    is_int($count/$numcols)) {
            echo 
    "</tr><tr>";
            
    $row=-1;
        }
        
    $count++;
        
    $row++;
    }
    while (
    $row<$numcols) {
        echo 
    "<td>&nbsp;</td>";
        
    $row++;
    }
    ?>
    </tr></table>


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
  •