Highly Recommended :

shown OR max='LIFETIME') and userid='".$userid."' ORDER BY RAND() LIMIT 1"); while($each = mysql_fetch_array($sql)) { mysql_query ("update banners set shown=shown+1 where id=".$each["id"]); $banner[] = array("image"=>$each["bannerurl"],"url"=>$domain."/bannerclick.php? id=".$each["id"]."&code=".$each['code']); } $sql = mysql_query("SELECT * FROM textlinks WHERE approved=1 AND views$info['subject'], "url"=> $domain."/textlinkclick.php?id=".$info['id']."&code=".$info['code']); } $banner_left = $banner_count-count($banner); $text_left = $text_count-count($text); if($banner_left>0) { $sql = mysql_query("SELECT * FROM banners where status=1 and (max>shown OR max='LIFETIME') ORDER BY RAND() LIMIT $banner_left"); while($each = mysql_fetch_array($sql)) { mysql_query ("update banners set shown=shown+1 where id=".$each["id"]); $banner[] = array ("image"=>$each["bannerurl"],"url"=>$domain."/bannerclick.php?id=".$each["id"]."&code=".$each['code']); } } if($text_left>0) { $sql = mysql_query("SELECT * FROM textlinks WHERE approved=1 AND views$info['subject'], "url"=> $domain."/textlinkclick.php?id=".$info['id']."&code=".$info['code']); } } $banner_left = $banner_count-count ($banner); $text_left = $text_count-count($text); if($banner_left>0) { $sql = mysql_query("SELECT * FROM adminbanner ORDER BY rand() LIMIT $banner_left"); while($each = mysql_fetch_array($sql)) { mysql_query("UPDATE adminbanner SET views=views+1 WHERE id='".$each['id']."'"); $banner[] = array("image"=>$each ['banner'],"url"=>$domain."/bannerclick2.php?id=".$each['id']); } } for ($i = 0; $i < $banner_count; $i++) { if(isset ($banner[$i])) { echo "
"; } else { echo "
 
"; } if(isset($text[$i])) { echo "". $text[$i]['text']."
"; } else { echo "
 
"; } echo "
"; } echo ""; ?>