Jak chcesz to ogarnąć w PHP, to podmień ostatnie linijki z tego kawałka kodu co wkleiłeś:
print("<table $w_1 class='text' border='0' cellspacing='1' cellpadding='0'></tr>"); while ($row = mysqli_fetch_assoc($result))
{
$id = $row['id'];
$name = $row['name'];
$poster = $row['poster'];
$hits = $row['added'];
print("<td class='image_poster'><a href=$BASEURL/details.php?id=$id title=\"$name\"><img src=".$row["poster"]." width=\"80\" height=\"110\" title=\"$name\" style='border:1px solid #000;' class='okladkabig'/></a><br /><b>dodano:</b> <span class='dodano'>$hits</span></td>"); }
Na to:
$filmsInCategory = $result->fetch_all(MYSQLI_ASSOC);
echo '<table ' . $w_1 . ' class="text" border="0" cellspacing="1" cellpadding="0">';
foreach ($filmsChunks as $chunk) {
foreach ($chunk as $row) {
$id = $row['id'];
$name = $row['name'];
$poster = $row['poster'];
$hits = $row['added'];
$href = sprintf('%s/details.php?id=%d', $BASEURL, $id);
echo '<td class="image_poster"> <a href="' . $href . '" title="' . $name . '">
<img src="' . $poster . '" width="80" height="110" title="' . $name . '" style="border:1px solid #000;" class="okladkabig" />
</a><br/>
<b>dodano:</b> <span class="dodano">' . $hits . '</span>
</td>';
}
}