Jump to content


Photo

Tables and Layout


  • Please log in to reply
1 reply to this topic

#1 Moon-Man.net

Moon-Man.net
  • Members
  • PipPipPip
  • Advanced Member
  • 84 posts

Posted 07 June 2006 - 06:25 AM

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?

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>";
That puts out a list like this

ITEM...
ITEM...
ITEM...
ITEM...
ITEM...
ITEM...
ITEM...
ITEM...
But i want it to look like this:

ITEM...     ITEM...
ITEM...     ITEM...
ITEM...     ITEM...
ITEM...     ITEM...

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


ITEM...     ITEM...     ITEM...
ITEM...     ITEM...     ITEM...
ITEM...     ITEM...     ITEM...
ITEM...     ITEM...     ITEM...
Cheers,
Nathan

#2 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 07 June 2006 - 08:04 AM

<?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>";
?>

Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users