10dawei
新手上路

UID 115021
精华
0
积分 13
帖子 9
金钱 13 喜悦币
威望 0
人脉 0
阅读权限 10
注册 2008-3-18
状态 离线
|
JS+PHP广告横幅 仿DZ
我是新手大家不要笑我哦 ~!
这个是主管让做个广告系统 虽然不是很难 但是希望对大家有帮助
我研究了一晚上研究出来的结果
<?php
include("include/db.php");
if(!empty($_GET['id'])){
$id=$_GET['id'];
}
$sql=mysql_fetch_array(mysql_query("select * from gg where id='$id'"));
$name=$sql['name'];//广告名称
$tupiandz=$sql['tupiandz'];//广告图片地址
$k=$sql['k'];//宽
$g=$sql['g'];//高
$lj=$sql['lj'];//超级连接
$sid=$sql['sid'];//分类名称
$lz=$sql['lz'];//类型
if(empty($sql['name'])){
exit;
}
else
{
if($lz=="flash"){
exit("document.write(\"<div id=$lz style=position: absolute;visibility:visible;z-index:1><a href=$lj><EMBED src=$tupiandz quality=high WIDTH=$k HEIGHT=$g TYPE=application/x-shockwave-flash id=dl></EMBED></a></div>\");");
}
else{
exit("document.write(\"<div id=$lz><a href=$lj><img src=$tupiandz width=$k height=$g border=0 /></a></div>\");");
}
}
?>
调用JS 后台插入数据 给出JS代码
<script language="JavaScript" src="http://localhost/phpcms/js.php?id=2"></script>
这是原JS 我认为还是PHP改良一下方便
function winload()
{
var adSrc = "http://www.a.com.cn/img/banner-logo/ld2008.swf";
var adFlash = "flash";
var adWidth = 90;
var adHeight = 90;
var adhref= "http://www.hao123.com"
if (adFlash == "flash")
{
document.write("<div id='"+adFlash+"' style='position: absolute;visibility:visible;z-index:1'><a href='"+adhref+"'><EMBED src='"+adSrc+"' quality=high WIDTH='"+adWidth+"' HEIGHT='"+adHeight+"' TYPE='application/x-shockwave-flash' id=dl></EMBED></a></div>");
}
if (adFlash == "gif")
{
document.write("<div id='"+adFlash+"'><a href='"+adhref+"'><img src='"+adSrc+"' width='"+adWidth+"' height='"+adHeight+"' /></a></div>");
}
}
winload()
大家见笑了~!
|
|