<?php 
   $adv_top=mysql_query("Select * From tbladvertise WHERE type='top' ORDER BY id ASC"); 
?>
<div class="clear" style="height: 3px;"></div>
<?php while($row_adv_top=mysql_fetch_array($adv_top)){ 
   if(!empty($row_adv_top['image'])){
      if(!empty($row_adv_top['link'])){
         echo '<a href="'.htmlspecialchars($row_adv_top['link']).'" target="_blank"><div id="box_bd_ads">
         <div id="img_ads" style="overflow: hidden; text-align: center;">
            <img src="images/ads/'.$row_adv_top['image'].'" style="width:100%; height:107px; object-fit:cover; border:0;" />
         </div></div></a>';
      }else{
         echo '<div id="box_bd_ads"><div id="img_ads" style="overflow: hidden; text-align: center;">
            <img src="images/ads/'.$row_adv_top['image'].'" style="width:100%; height:107px; object-fit:cover; border:0;" />
         </div></div>';
      }
   }
} 
?>
<div class="clear" style="height: 20px;"></div>