Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Nov 2003
    Posts
    77
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Output Data to table (need column help)

    Hey there, need some help here.. im stuck

    What I have is a for loop that goes through and outputs an ip address to a table cell, each recursion creates a new row and prints the address... so basically what im left with is a very long 1x1 table.

    now im happy that my code works for generating the table, but what im wondering is, is there a way i can "wrap" the table at the bottom and create a new column when the table reaches the bottom of the screen?

    basically turning it into a 1x2 table.. (or 1x3, 1x4, etc)

    is this possible?

    Code:
    $infocount = 18; 
    $timeout = 2; 
    
    echo '<table width="500" border="0" align=left>'; 
    for($i=0; $i<=$infocount; $i++){ 
    	$fp = @fsockopen ($info[$i]["address"], $info[0]["port"], $errno, $errstr, $timeout); 
    	if ($fp) { 
    		echo "<tr><td width=50><img src='images/up2.gif' alt='Connected'></td><td width=450><a href='http://" . $info[$i]["address"] . "'>" . $info[$i]["name"] . "</a></td></tr>"; 
    	}else{ 
    		echo "<tr><td width=50><img src='images/down2.gif' alt='Down!'></td><td width=450>" . $info[$i]["name"] . "</td></tr>"; 
    	} 
    } 
    echo '</tr></table>'; 
    ?>
    hope that works... lol... can someone help me get the table to wrap itself to a new column once it starts showing scrollbars?

    thanks so much in advance!!
    i'm always learning

  • #2
    Regular Coder
    Join Date
    Mar 2008
    Posts
    118
    Thanks
    3
    Thanked 9 Times in 9 Posts
    Fumigator helped me with a similar problem before. You need to use the modulus operator (&#37. I'm not sure if you can create a new row simply when the scrollbars appear, but you can estimate how many cells it takes in order to make them appear.

    When you get this number, let's say 10, you need to check the modulus every time the loop runs. divide 10 by the variable $i (in your case). If the mod != 0 then allow the table to create normally, if the mod == 0 then include the html tags to create another column.

    You might need to nest your table within another tables' <td> so that other <td>'s in the nesting table can be made.


  •  

    Posting Permissions

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