<?php $result = mysql_query("SELECT * FROM sider") or die(mysql_error()); while($row = mysql_fetch_array( $result )) { echo "<td>"; echo "<a href='#'>"; echo "<div class='server_image' style='background-image:url(images/servers/game/"; echo $row['shortcut']; echo ".png)'></div>"; echo "</a>"; for ($i = 0; $i < count($shortcut); ++$i) echo (($i + 1) % 3 && $i != count($shortcut) - 1) ? '</td> ' : '</tr><tr>'; } ?>