Jump to content

Archived

This topic is now archived and is closed to further replies.

Moon-Man.net

Tables and Layout

Recommended Posts

Hey forum.
I have this loop wich with all my other code displayes all the tables in a database and create's a select box for them. This is all good and working. But how can i make it that when it loops over a certain amount of times it will display all the select boxes after the ammount beside the original ones?

[code]echo "<table border='1'>";
        // For each row, print the name!
for ($j=0; $j < $field_count; $j++) {
            echo "<tr>";
            $field = pg_fieldname($sql_query,$j);
            echo "<td><input type='checkbox' name=$field value=$field checked='checked'></td>";
          echo "<td>View--$field </td>";
          echo "</tr>";
    }
    echo "</table>";
    echo "<hr>";[/code]
That puts out a list like this

[code]
ITEM...
ITEM...
ITEM...
ITEM...
ITEM...
ITEM...
ITEM...
ITEM...
[/code]
But i want it to look like this:

[code]
ITEM...     ITEM...
ITEM...     ITEM...
ITEM...     ITEM...
ITEM...     ITEM...
[/code]

With a while loop, but how? And if it has over a second ammount, display them next to that!


[code]
ITEM...     ITEM...     ITEM...
ITEM...     ITEM...     ITEM...
ITEM...     ITEM...     ITEM...
ITEM...     ITEM...     ITEM...
[/code]
Cheers,
Nathan

Share this post


Link to post
Share on other sites
[code]
<?php
$field_count = 50; //example # of results
$colnum = 10; //example heigth of column

echo "<table border='1'><tr><td valign = 'top'>";
echo "<table border='1'>";
$x = 1;
for ($j = 0; $j < $field_count; $j++) {
     echo "<tr>";
   echo "<td><input type='checkbox' name='field' value='blah' checked='checked'></td>";
          echo "<td>View--$j </td>";
          echo "</tr>";
   if ($x == '10') {
       echo "</table></td><td valign='top'><table border='1'>";
         $x = 0;
     }
     $x++;
}
echo "</td></tr></table>";
?>
[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.