Moon-Man.net Posted June 7, 2006 Share Posted June 7, 2006 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 Link to comment https://forums.phpfreaks.com/topic/11389-tables-and-layout/ Share on other sites More sharing options...
.josh Posted June 7, 2006 Share Posted June 7, 2006 [code]<?php$field_count = 50; //example # of results$colnum = 10; //example heigth of columnecho "<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] Link to comment https://forums.phpfreaks.com/topic/11389-tables-and-layout/#findComment-42714 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.