PDA
Partners

View Full Version : Making new rows


circuitjump
January 23rd, 2004, 02:22 PM
Hi All, This is my first post here at webmasterlingo.com. :) Yaaayyy!!!

I have a small problem that needs solved and I'm running out of ideas to solve it, so I come to the members of this site seeking help.

I have an html table that prints out info passed to it by MySQL. The problem is that some entries are more then 10. what I want it to do is when it hits the first ten, start a new row. So visually it looks like this.

----------------------------------------
tex | text | text // this goes up to ten
----------------------------------------
tex | text | text // this goes up to ten too
----------------------------------------

And at that point I want it to create a new <tr></tr> for the rest of the entries

Here is the code at the moment. It might be a little confusing but any help would be greatly appreciated.


while ($count_against <= $count_rooms) {
// this is where I want to tell it to start a new html table row when it hits 10
if () {
print "<tr>\n";
while ($count_against <= $count_rooms) {
//while ($count_against <= 10) {
print "<td width=\"75\" align=\"center\" valign=\"top\"><div class=\"mainTextMargin\">&nbsp;".$room_title[$count_against]."</div></td>";
$count_against++;
}
$width = 75*$count_against-750;
print "<td width=".$width.">&nbsp;</td>";
print "</tr>\n";
print "<tr>";
print "<td height=\"1\" colspan=\"45\" class=\"tdBlack\"><img src=\"images/trans.gif\" width=\"1\" height=\"1\"></td>";
print "</tr>";
print "<tr>";
$count_against = 0;
while ($count_against <= $count_rooms) {
//while ($count_against <= 10) {
print "<td width=\"75\" align=\"center\" valign=\"top\"><div class=\"mainTextMargin\">&nbsp;".$room_dimensions[$count_against]."</div></td>";
$count_against++;
}
$width = 75*$count_against-750;
print "<td width=".$width.">&nbsp;</td>";
print "</tr>";
}
}
?>

ZYV
January 23rd, 2004, 02:29 PM
Try


while ($count_against <= $count_rooms) {
// this is where I want to tell it to start a new html table row when it hits 10
$n = 0;
if ($n < 10) {
......... your old code ....
$n++;
}

circuitjump
January 23rd, 2004, 04:32 PM
Thanks,

I went about a different way less robust but it does the trick, so I'm gonna go ahead and test your way and some other ways this weekend and see what I can come up with.

Thanks for the help :)

kitty
August 31st, 2005, 07:44 AM
im agree with the one who send this code im tried it before
while ($count_against <= $count_rooms) {
// this is where I want to tell it to start a new html table row when it hits 10
$n = 0;
if ($n < 10) {
......... your old code ....
$n++;
}