AbydosGater Posted March 31, 2007 Share Posted March 31, 2007 Hey, Im running a game script. And the popular games box that displays under the game is in a table.. The code that generates the table is.. <div class="box"> <h1>Most Popular: <?php echo $gameset->games[$id]->category; ?></h1> <table class="game" cellspacing="1"><tr> <?php $count = 0; $x = 0; foreach($gameset->GetGames(array('categoryID' => array($gameset->games[$id]->categoryID, true)), 'plays', false, 0, 6, $x) as $gameID) { echo '<td>'; $gameset->games[$gameID]->DisplaySmall(); echo '</td>'; $count ++; if($count == 3) { $count = 0; echo '</tr><tr>'; } } while($count < 3 && $count != 0) { echo '<td></td>'; $count ++; } ?> </tr></table> </div> It used to count to only 2 <td>'s but i want three so i set it to three.. But if you look at http://gameroyal.com/play-1244-Territory_War.html at the popular games box, the last <td>, the new one is all messed up and squashed. I tried editing the css but it made no difference. Does anyone know how i can fix this? (PS: I tried the Scripts support, There was no reply ) Andy Link to comment https://forums.phpfreaks.com/topic/45051-problem-with-table-generator/ Share on other sites More sharing options...
shocker-z Posted March 31, 2007 Share Posted March 31, 2007 Try this mate <div class="box"> <h1>Most Popular: <?php echo $gameset->games[$id]->category; ?></h1> <table class="game" cellspacing="1"><tr> <?php $count = 0; $x = 0; foreach($gameset->GetGames(array('categoryID' => array($gameset->games[$id]->categoryID, true)), 'plays', false, 0, 6, $x) as $gameID) { if($count == 0) { echo '<tr>'; } echo '<td>'; $gameset->games[$gameID]->DisplaySmall(); echo '</td>'; $count ++; if($count == 3) { $count = 0; echo '</tr>'; } } while($count < 3 && $count != 0) { echo '<td></td>'; $count ++; } ?> </tr></table> </div> modified so if equal to 0 which means new row then it echo's <tr> and if it's equal to 3 then it echo's </tr> before you were opening a new row at the end no matter what the result. Regards Liam Link to comment https://forums.phpfreaks.com/topic/45051-problem-with-table-generator/#findComment-218747 Share on other sites More sharing options...
AbydosGater Posted March 31, 2007 Author Share Posted March 31, 2007 Ok great thanks seams to be working now Andy Link to comment https://forums.phpfreaks.com/topic/45051-problem-with-table-generator/#findComment-218800 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.