你连问题是什么都没说怎么答??

解决方案 »

  1.   

    嘿.偶今天也写了个广告显示程序...以下是片断//统计出该库的总记录数,并算出一个随机数
    $db->query('select ads_id from t_ads');
    $db_count = $db->num_rows();
    if(!$db_count) {
    echo "<center>广告招商,详情请联系<a href='mailto:$admin_email?subject=关于广告招商'>$admin_email</a></center>";
    exit;
    }
    srand((double)microtime()*1000000);
    $sql = 'select * from t_ads limit '.(rand(1,$db_count)-1).',1';
    @$db->query($sql) or die(数据库查询出错);
    $db->next_obj();//显示广告代码开始,以下代码可以自动判断广告条格式为swf或gif
    if (substr($records->ads_img,-4) == '.swf'):
    ?>
    <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="468" height="60">
    <param name="movie" value="images/ads/<?=$records->ads_img?>">
    <param name="quality" value="high">
    <param name="menu" value="false">
    <embed src="images/ads/<?=$records->ads_img?>" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="468" height="60">
    </embed></object>
    <?
    else:
    ?>
    <a href="<?=$records->ads_link?>" target="_blank">
    <img src="images/ads/<?=$records->ads_img?>" border="0" width="468" height="60" alt="<?=$records->ads_memo?>">
    </a>
    <?
    endif;
    //判断广告显示代码结束$sql='update t_ads set ads_num='.($records->ads_num+1).' where ads_id='.$records->ads_id;
    @$db->query($sql) or die ("更新数据库出错!");
    ?>