burda sorun php değil html...
while döngüsüne almışsın ama div'lerin başı while'ın içinde sonu while'ın dışında, yani 4 tane div içiyorsun ama 1 tane kapatıyorsun bu durumda. altta while'den itibaren kısmı yazıyorum, koyu ile yazdığım yerleri dğeiştir.

<div id="Layer21">
// bu kısmıda while'dan sonraya koy, yani <table> başlangıcının üstüne
<?php
while ($bas = mysql_fetch_array($sorgu))
{
?>
<table width="102" height="93" border="1" cellpadding="1" cellspacing="1">
<tr>
<th scope="col"><a href=urun.php?id=<?php echo "".$bas[id].""; ?>><img width="102" height="88" src=fotolar/<?php echo "".$bas[resmi].""; ?>></a></th>
</tr>
</table>
</div>
<div id="Layer19">
<table width="315" border="1" cellspacing="10" cellpadding="5">
<tr>
<th scope="col">Kodu:</th>
<th scope="col"><?php echo "".$bas['kod'].""; ?></th>
</tr>
<tr>
<th scope="col">Tipi:</th>
<th scope="col"><?php echo "".$bas['tipi'].""; ?></th>
</tr>
</table><br />
<?php } ?>
</div> //bu kısmı yukardaki satırın üstüne koy
<div id="Layer20"></div>
<table width="890" height="768" border="1" cellpadding="5" cellspacing="10" background="tablebg.gif">
<tr>
<th bordercolor="#000000" background="tablebg.gif" scope="col"><span class="style4"></span></th>
</tr>
</table><br />