当前位置: 编程技术>php
本页文章导读:
▪BBS(php & mysql)完整版(七)
//下面是 top.js function KB_keepItInIE(theName,theWantTop,theWantLeft) { theRealTop=parseInt(document.body.scrollTop) theTrueTop=theWantTop+theRealTop document.all[theName].style.top=theTrueTop theRealLeft=parseInt(document.body.scr.........
▪用PHP实现小型站点广告管理(修正版)
今天做照着例子做,发现其中有很多错误的地方,为了让广大菜鸟兄弟更好的理解,我把修改后的文件给大家看看。 数据结构如下: CREATE TABLE ad ( url varchar(100) NOT NULL, banner varchar(150) NOT NULL.........
▪BBS(php & mysql)完整版(二)
//此页面为look.php <? include "signup/mysql.inc"; $sql="select * from ".$table." where id='$id'"; $result=mysql_query($sql)or die(mysql_error()); $row=mysql_fetch_array($result); $number=++$row["number"]; $sql="update $table set number='$numb.........
[1]BBS(php & mysql)完整版(七)
来源: 互联网 发布时间: 2013-11-30
//下面是 top.js
function KB_keepItInIE(theName,theWantTop,theWantLeft) {
theRealTop=parseInt(document.body.scrollTop)
theTrueTop=theWantTop+theRealTop
document.all[theName].style.top=theTrueTop
theRealLeft=parseInt(document.body.scrollLeft)
theTrueLeft=theWantLeft+theRealLeft
document.all[theName].style.left=theTrueLeft
}
function KB_keepItInNN(theName,theWantX,theWantY) {
theRealLay=document.layers[theName]
theBadX=self.pageYOffset
theBadY=self.pageXOffset
theRealX=theBadX+theWantX
theRealY=theBadY+theWantY
theRealLay.moveTo(theRealY,theRealX)
}
IE4=(document.all)?1:0
NN4=(document.layers)?1:0
//if (IE4)
//setInterval('KB_keepItInIE("KBStatic",0,0)',1)
//if (NN4)
//setInterval('KB_keepItInNN("KBStatic",0,0)',1)
//下面是menu.php
<div id="Layer1" >
<script language="JavaScript1.2">fwLoadMenus();
</script></div>
<SCRIPT LANGUAGE="JavaScript">
<!--
if (IE4)
setInterval('KB_keepItInIE("Layer1",0,31)',1)
if (NN4)
setInterval('KB_keepItInNN("Layer1",0,31)',1)
//-->
</SCRIPT>
//下面是 menuhead.php
<?
echo "<script language=JavaScript1.2 src='/blog_article/js/menu_comment.js'></script><script language=JavaScript1.2 src='/blog_article/js/fw_menu.js'></script><script language=JavaScript1.2 src='/blog_article/js/top.js'></script>";
?>
//下面为mysql.inc
<?
$link=mysql_pconnect("localhost","xiaoyang","xiaoyang")or die(mysql_error());
$link1=mysql_select_db("database")or die(mysql_error());
?>
function KB_keepItInIE(theName,theWantTop,theWantLeft) {
theRealTop=parseInt(document.body.scrollTop)
theTrueTop=theWantTop+theRealTop
document.all[theName].style.top=theTrueTop
theRealLeft=parseInt(document.body.scrollLeft)
theTrueLeft=theWantLeft+theRealLeft
document.all[theName].style.left=theTrueLeft
}
function KB_keepItInNN(theName,theWantX,theWantY) {
theRealLay=document.layers[theName]
theBadX=self.pageYOffset
theBadY=self.pageXOffset
theRealX=theBadX+theWantX
theRealY=theBadY+theWantY
theRealLay.moveTo(theRealY,theRealX)
}
IE4=(document.all)?1:0
NN4=(document.layers)?1:0
//if (IE4)
//setInterval('KB_keepItInIE("KBStatic",0,0)',1)
//if (NN4)
//setInterval('KB_keepItInNN("KBStatic",0,0)',1)
//下面是menu.php
<div id="Layer1" >
<script language="JavaScript1.2">fwLoadMenus();
</script></div>
<SCRIPT LANGUAGE="JavaScript">
<!--
if (IE4)
setInterval('KB_keepItInIE("Layer1",0,31)',1)
if (NN4)
setInterval('KB_keepItInNN("Layer1",0,31)',1)
//-->
</SCRIPT>
//下面是 menuhead.php
<?
echo "<script language=JavaScript1.2 src='/blog_article/js/menu_comment.js'></script><script language=JavaScript1.2 src='/blog_article/js/fw_menu.js'></script><script language=JavaScript1.2 src='/blog_article/js/top.js'></script>";
?>
//下面为mysql.inc
<?
$link=mysql_pconnect("localhost","xiaoyang","xiaoyang")or die(mysql_error());
$link1=mysql_select_db("database")or die(mysql_error());
?>
[2]用PHP实现小型站点广告管理(修正版)
来源: 互联网 发布时间: 2013-11-30
今天做照着例子做,发现其中有很多错误的地方,为了让广大菜鸟兄弟更好的理解,我把修改后的文件给大家看看。
数据结构如下:
CREATE TABLE ad (
url varchar(100) NOT NULL,
banner varchar(150) NOT NULL,
alt varchar(100),
priority int(4) DEFAULT '1' NOT NULL,
)
增加广告的文件
***************putad.php********************
<? if($submit){
//处理表单数据的PHP程序;
//图片banner名和链接地址不能为空;
if (( banner!="") & ( url!="")) {
//若广告链接和图片名已被使用,必须另选;
if (file_exists("adbanner/". $banner_name)) {
echo "广告图片. banner_name.已被使用,请另选!";
exit;
};
//上传链接图片文件名到adbanner目录;
copy( $banner,"adbanner/". $banner_name);
//连接MySQL数据库;
include("config.inc");
//向数据表ad中插入来自于表单的新数据;
$query="insert into ad (url, alt, priority, banner) values('$url','$alt','$priority','$banner_name')";
//插入成功则显示以下信息;
$try=mysql_query($query);
if($try){
echo "一条广告新增完成,详细信息:";
echo "";
echo "广告网址: $url
广告链接说明: $alt
显示加权: $priority ";
}else{echo "出错";}
}
}else{
?>
<html>
<head>
<title>Untitled</title>
</head>
<body bgcolor="#ffffff">
<p>广告交换表</p>
<form method="post" action="/blog_article/putad.html" enctype="multipart/form-data">
<p>图 片 URL:
<input type="file" name="banner">
</p>
<p>连接 URL:
<input type="text" name="url">
</p>
<p>显示权数:
<input type="text" name="priority"></p>
<p>连接说明:
<input type="text" name="alt">
</p>
<p>
<input type="submit" name="submit" value="确定">
<input type="reset" name="concel" value="重填">
</p>
</form>
</body>
</html> <?}?>
***************showad.php********************
<?
include("config.inc");
$query="SELECT url, banner, alt, priority from ad";
$result=mysql_query($query);
$numrows=mysql_num_rows($result);
//使用mysql_fetch_object()函数获取有用的列信息并存到相应数组中;
while($row = mysql_fetch_object($result)) {
$adurl[]=$row->url;
$adbanner[]=$row->banner;
$adalt[]=$row->alt;
$adpriority[]=$row->priority;
}
//初始化中间变量;
$numcheck=$numrows;
$i=$pricount=0;
//得到最大随机数;
while($numcheck) {
$pricount+=$adpriority[$i];
$i++; $numcheck--;
}
//程序执行时的百万分之一秒产生随机数种子;
srand((double)microtime()*1000000);
//得到1到最大随机数之间的一个随机数;
$pri= rand(1,$pricount);
//中间变量清零;
$pricount=0;
//按加权值不同,产生用来显示广告的、元素为字串的数组;
for($i=0;$i<$numrows;$i++) {
$pricount+=$adpriority[$i];
if ($pri<=$pricount) {
$ad[]="<a href=/blog_article/$adurl[$i]><img/index.html src=/blog_article/adbanner/$adbanner[$i]/index.html alt=$adalt[$i] border=0></a>";
}
}
//显示广告,权值越大,显示机会越大;
echo $ad[0];
?>
注释:其中config.inc里面就是连接mysql数据库的东西,在这就不列出来了。上面的程式还有改进空间,还有好多功能没实现,如果你愿意你也可以修改。不过修改后最好给一份给我:terence611005@sina.com
有问题请和我联系:oicq:18680986
数据结构如下:
CREATE TABLE ad (
url varchar(100) NOT NULL,
banner varchar(150) NOT NULL,
alt varchar(100),
priority int(4) DEFAULT '1' NOT NULL,
)
增加广告的文件
***************putad.php********************
<? if($submit){
//处理表单数据的PHP程序;
//图片banner名和链接地址不能为空;
if (( banner!="") & ( url!="")) {
//若广告链接和图片名已被使用,必须另选;
if (file_exists("adbanner/". $banner_name)) {
echo "广告图片. banner_name.已被使用,请另选!";
exit;
};
//上传链接图片文件名到adbanner目录;
copy( $banner,"adbanner/". $banner_name);
//连接MySQL数据库;
include("config.inc");
//向数据表ad中插入来自于表单的新数据;
$query="insert into ad (url, alt, priority, banner) values('$url','$alt','$priority','$banner_name')";
//插入成功则显示以下信息;
$try=mysql_query($query);
if($try){
echo "一条广告新增完成,详细信息:";
echo "";
echo "广告网址: $url
广告链接说明: $alt
显示加权: $priority ";
}else{echo "出错";}
}
}else{
?>
<html>
<head>
<title>Untitled</title>
</head>
<body bgcolor="#ffffff">
<p>广告交换表</p>
<form method="post" action="/blog_article/putad.html" enctype="multipart/form-data">
<p>图 片 URL:
<input type="file" name="banner">
</p>
<p>连接 URL:
<input type="text" name="url">
</p>
<p>显示权数:
<input type="text" name="priority"></p>
<p>连接说明:
<input type="text" name="alt">
</p>
<p>
<input type="submit" name="submit" value="确定">
<input type="reset" name="concel" value="重填">
</p>
</form>
</body>
</html> <?}?>
***************showad.php********************
<?
include("config.inc");
$query="SELECT url, banner, alt, priority from ad";
$result=mysql_query($query);
$numrows=mysql_num_rows($result);
//使用mysql_fetch_object()函数获取有用的列信息并存到相应数组中;
while($row = mysql_fetch_object($result)) {
$adurl[]=$row->url;
$adbanner[]=$row->banner;
$adalt[]=$row->alt;
$adpriority[]=$row->priority;
}
//初始化中间变量;
$numcheck=$numrows;
$i=$pricount=0;
//得到最大随机数;
while($numcheck) {
$pricount+=$adpriority[$i];
$i++; $numcheck--;
}
//程序执行时的百万分之一秒产生随机数种子;
srand((double)microtime()*1000000);
//得到1到最大随机数之间的一个随机数;
$pri= rand(1,$pricount);
//中间变量清零;
$pricount=0;
//按加权值不同,产生用来显示广告的、元素为字串的数组;
for($i=0;$i<$numrows;$i++) {
$pricount+=$adpriority[$i];
if ($pri<=$pricount) {
$ad[]="<a href=/blog_article/$adurl[$i]><img/index.html src=/blog_article/adbanner/$adbanner[$i]/index.html alt=$adalt[$i] border=0></a>";
}
}
//显示广告,权值越大,显示机会越大;
echo $ad[0];
?>
注释:其中config.inc里面就是连接mysql数据库的东西,在这就不列出来了。上面的程式还有改进空间,还有好多功能没实现,如果你愿意你也可以修改。不过修改后最好给一份给我:terence611005@sina.com
有问题请和我联系:oicq:18680986
[3]BBS(php & mysql)完整版(二)
来源: 互联网 发布时间: 2013-11-30
//此页面为look.php
<?
include "signup/mysql.inc";
$sql="select * from ".$table." where id='$id'";
$result=mysql_query($sql)or die(mysql_error());
$row=mysql_fetch_array($result);
$number=++$row["number"];
$sql="update $table set number='$number' where id='$id'";
mysql_query($sql)or die(mysql_error());
?>
<html>
<head>
<title>xiaoyang</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<?
include "js/menuhead.php"
?>
<script language="JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
// -->
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<?
include "js/menu.php";
?>
<div id="Layer6" ></div>
<div id="Layer5" >
<table width="100%" border="1" cellspacing="0" cellpadding="0" bordercolor="#FFCCFF">
<tr>
<td width="22%" height="17">
<div align="center"><font color="#FF3399" size="2">题目</font></div>
</td>
<td width="78%" height="17">
<div align="center"><font size="2" color="#9966FF"><?echo $row["title"] ;?></font> </div>
</td>
</tr>
<tr>
<td width="22%" height="24">
<div align="center"><font color="#FF3399" size="2">作者</font></div>
</td>
<td width="78%" height="24">
<div align="center"><font size="2" color="#9966FF"><?echo $row["userid"] ;?></font> </div>
</td>
</tr>
<tr>
<td width="22%">
<div align="center"><font color="#FF3399" size="2">内容</font></div>
</td>
<td width="78%">
<div align="left"><font size="2" color="#9966FF"><? $file=explode("n",$row["content"]); $num=count($file);
for($i=0 ;$i<$num;$i++) echo " ".$file[$i]."<BR>";?></font></div>
</td>
</tr>
</table>
<?
for($j=1;$j<6;$j++) //显示回复内容
{
$re="r".$j;
if($row["$re"])
{
$id2=$row["$re"];
$sql="select * from bbs_re where id='$id2'";
$result=mysql_query($sql)or die(mysql_error());
$row8=mysql_fetch_array($result);
echo "<BR>";
echo " <table width=100% border=1 cellspacing=0 cellpadding=0 bordercolor=#FFCCFF> <tr>";
echo " <td width=22% height=17> <div align=center><font color=#FF3399 size=2>题目</font></div>";
echo " </td> <td width=78% height=17>";
echo " <div align=center><font size=2 color=#9966FF>".$row8["title"]."</font> </div> </td> </tr> <tr>";
echo "<td width=22% height=24>";
echo "<div align=center><font color=#FF3399 size=2>作者</font></div></td>";
echo " <td width=78% height=24>";
echo "<div align=center><font size=2 color=#9966FF>".$row8["userid"]." </font> </div></td> </tr><tr>";
echo " <td width=22%><div align=center><font color=#FF3399 size=2>内容</font></div>";
echo "</td> <td width=78%>";
echo "<div align=left><font size=2 color=#9966FF>"; $file=explode("n",$row8["content"]);
$num=count($file);
for($i=0 ;$i<$num;$i++) echo " ".$file[$i]."<BR>";
echo "</font></div>";
echo " </td> </tr> </table>";
}
}
?>
<BR><BR>
</div>
<div id="back" >
<hr color="#ff9999" noshade>
</div>
<div id="goback" >
<div align="center"><a href="/blog_article/php3/p/1/amp;/amp;table/lt;echo $table ;/gt;.html" target="_self" onMouseOver="window.status=''; return true"><font size="2" color="#FF33FF">返回</font></a></div>
</div>
<div id="Lay" >
<hr noshade color="#ff9999">
</div>
<div id="Laye" >
<div align="center"><a href="/blog_article/say/id1/lt; echo $id..html"&&table=".$table ;?>" target="_self" onMouseOver="window.status='';return true"><font size="2" color="#FF33FF">回复</font></a></div>
</div>
<p> </p>
<p> </p>
</body>
</html>
<?
include "signup/mysql.inc";
$sql="select * from ".$table." where id='$id'";
$result=mysql_query($sql)or die(mysql_error());
$row=mysql_fetch_array($result);
$number=++$row["number"];
$sql="update $table set number='$number' where id='$id'";
mysql_query($sql)or die(mysql_error());
?>
<html>
<head>
<title>xiaoyang</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<?
include "js/menuhead.php"
?>
<script language="JavaScript">
<!--
function MM_reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
// -->
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<?
include "js/menu.php";
?>
<div id="Layer6" ></div>
<div id="Layer5" >
<table width="100%" border="1" cellspacing="0" cellpadding="0" bordercolor="#FFCCFF">
<tr>
<td width="22%" height="17">
<div align="center"><font color="#FF3399" size="2">题目</font></div>
</td>
<td width="78%" height="17">
<div align="center"><font size="2" color="#9966FF"><?echo $row["title"] ;?></font> </div>
</td>
</tr>
<tr>
<td width="22%" height="24">
<div align="center"><font color="#FF3399" size="2">作者</font></div>
</td>
<td width="78%" height="24">
<div align="center"><font size="2" color="#9966FF"><?echo $row["userid"] ;?></font> </div>
</td>
</tr>
<tr>
<td width="22%">
<div align="center"><font color="#FF3399" size="2">内容</font></div>
</td>
<td width="78%">
<div align="left"><font size="2" color="#9966FF"><? $file=explode("n",$row["content"]); $num=count($file);
for($i=0 ;$i<$num;$i++) echo " ".$file[$i]."<BR>";?></font></div>
</td>
</tr>
</table>
<?
for($j=1;$j<6;$j++) //显示回复内容
{
$re="r".$j;
if($row["$re"])
{
$id2=$row["$re"];
$sql="select * from bbs_re where id='$id2'";
$result=mysql_query($sql)or die(mysql_error());
$row8=mysql_fetch_array($result);
echo "<BR>";
echo " <table width=100% border=1 cellspacing=0 cellpadding=0 bordercolor=#FFCCFF> <tr>";
echo " <td width=22% height=17> <div align=center><font color=#FF3399 size=2>题目</font></div>";
echo " </td> <td width=78% height=17>";
echo " <div align=center><font size=2 color=#9966FF>".$row8["title"]."</font> </div> </td> </tr> <tr>";
echo "<td width=22% height=24>";
echo "<div align=center><font color=#FF3399 size=2>作者</font></div></td>";
echo " <td width=78% height=24>";
echo "<div align=center><font size=2 color=#9966FF>".$row8["userid"]." </font> </div></td> </tr><tr>";
echo " <td width=22%><div align=center><font color=#FF3399 size=2>内容</font></div>";
echo "</td> <td width=78%>";
echo "<div align=left><font size=2 color=#9966FF>"; $file=explode("n",$row8["content"]);
$num=count($file);
for($i=0 ;$i<$num;$i++) echo " ".$file[$i]."<BR>";
echo "</font></div>";
echo " </td> </tr> </table>";
}
}
?>
<BR><BR>
</div>
<div id="back" >
<hr color="#ff9999" noshade>
</div>
<div id="goback" >
<div align="center"><a href="/blog_article/php3/p/1/amp;/amp;table/lt;echo $table ;/gt;.html" target="_self" onMouseOver="window.status=''; return true"><font size="2" color="#FF33FF">返回</font></a></div>
</div>
<div id="Lay" >
<hr noshade color="#ff9999">
</div>
<div id="Laye" >
<div align="center"><a href="/blog_article/say/id1/lt; echo $id..html"&&table=".$table ;?>" target="_self" onMouseOver="window.status='';return true"><font size="2" color="#FF33FF">回复</font></a></div>
</div>
<p> </p>
<p> </p>
</body>
</html>
最新技术文章: