Yesterday I tried to post an example for you, but I failed because of .... Anyway, I am trying to post it again now. Hope you can extract your required code from it
$i=45;
$j=0;
$total=850;
echo "<TABLE>";
while($j<$total)
{
if($j%$i==0)
{
echo "<TR>\n";
}
echo "<td style='border:1px solid gray'>".($j+1)."</td>\n";
$j++;
if($j%$i==0)
{
echo "</TR>\n";
}
}
for($k=0;$k<$i-$j%$i && $j%$i!=0;$k++)
{
echo "<td style='border:1px solid gray'></td>\n";
}
echo "</TABLE>";
You can modify it the way you want :D