This might not help you totally, because it's for my own script (not for this adoptables script), and it's for a shop, but it has a table which is made, making a new line every four columns.
PHP Code:
$page .= "This is the item shop. Here you can buy a multitude of items for your pet to play with or use.<br />";
$query = "SELECT * FROM ".$prefix."itemkinds WHERE kind='shop'";
$result = mysql_query($query);
$num = mysql_numrows($result);
$i=0;
$page .="<table style='border:0px;'><tr>";
while ($i<$num) {
// `id` , `name` , `desc` , `cost` , `kind` , `img`
$id=@mysql_result($result,$i,"id");
$name=@mysql_result($result,$i,"name");
$desc=@mysql_result($result,$i,"desc");
$cost=@mysql_result($result,$i,"cost");
$kind=@mysql_result($result,$i,"kind");
$img=@mysql_result($result,$i,"img");
if ((($i+1)%4)!=0) {
$page .= "<td style='width:25%;'><a href='shop.php?shop=item&buy={$id}'><img src='{$img}'></a><br />{$cost}</td>";
}
else {
$page .= "<td style='width:25%;'><a href='shop.php?shop=item&buy={$id}'><img src='{$img}'></a><br />{$cost}</td></tr><tr>";
}
$i++;
}
if ($i%4!=0) {
$page .= "</table>";
}
else {
$page .= "</tr></table>";
}