Jump to content

Problem with table generator


AbydosGater

Recommended Posts

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

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

Archived

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

×
×
  • Create New...

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.