一个另类php简单论坛的实现
时间:2007-02-17 来源:PHP爱好者
当然不用做任何注释
程序的显示部分完全可以用*.inc包括,
数据库 zclasslt
/********
id int not null
name varcher(20)
title varcher(50)
note text
rtitle int
******/
运行结果可以去zclass.oso.com.cn/zclasslt.php
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Zclass论坛</title>
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
</head>
<body bgcolor="#000000" text="#FFFFFF" vlink=800000 alink=800000 link=800000>
<div align=left>
<table border=0 bordercolordark=#FFFFFF cellpadding=0 cellspacing=0 width=743
height=36>
<tr>
<td bgcolor=#800000 height=34 width=737><marquee
direction=left border=0><u><font face=黑体 color=#ffffff size=5>就等着我泡到500分吧</font><font size=1>Zclass.yeah.net</font></u></td>
</tr>
</table>
</div>
<form method=post action="<?echo $PATH_INFO;?>">
<?
$db=mysql_connect("localhost","root");
mysql_select_db("zclasslt",$db);
$result=mysql_query("SELECT * FROM zclasslt",$db);
if($submit){
$zclasslttime=date("y,m,d");
$result = mysql_query("SELECT * FROM zclasslt",$db);
while($myrow=mysql_fetch_array($result)){
$thetext=$myrow["note"];
}
if($zclasslttextarea==""||$zclasslttextarea==$thetext){
$error="<br> <font face=黑体 size=5>请</font><br> <font face=黑体 size=5>填</font><br> <font face=黑体 size=5>写</font><br> <font face=黑体 size=5>留</font><br> <font face=黑体 size=5>言</font>";
print( $error);}
else {
if($zclassltname=="")
{ $zclassltname="匿名";}
if($zclasslttitle==""){
$zclasslttitle="无题";
}
if($test){
$zclassltrtitle=$testid;
$sql="UPDATE zclasslt SET rtitle=1 WHERE ID=$testid";
$result=mysql_query($sql);
}else{$zclassltrtitle=$test;}
$sql="INSERT INTO zclasslt(name,title,note,time,rtitle)
VALUES('$zclassltname','$zclasslttitle','$zclasslttextarea','$zclasslttime','$zclassltrtitle')";
$result=mysql_query($sql);
$result = mysql_query("SELECT * FROM zclasslt",$db);
$maxid=0;
while($myrow=mysql_fetch_array($result)){
if($maxid<$myrow["id"])
$maxid=$myrow["id"];
}
$i=$maxid;
print("
<div align=left><left>
<table border=0 width=732 height=60 cellspacing=0 cellpadding=0
>
<tr>
<td width=349 height=60 valign=top align=left background=bubbles.jpg><div align=center><center><table
border=1 width=74 height=114 cellspacing=0 cellpadding=0 bgcolor=#800000>
<tr>
<td width=98 height=114 valign=top align=left><a href=index.php><img src=zclass2.jpg width=96
height=246 alt=垃圾制造></a></td>
<td width=394 height=114 valign=top align=right bgcolor=#800000><textarea
name=zclasslttextarea rows=12 cols=32></textarea><font face=黑体 size=4>标题</font>:<input type=text
name=zclasslttitle size=26><font face=黑体 size=4>姓名</font>:<input type=text name=zclassltname size=19> <input
type=submit name=submit value=提交><input type=hidden name=test value=0></td>
</tr>
</table>
</center></div><img src=rubbish.jpg></td>
<td width=383 height=60 cellpadding=0 cellspacing=0 valign=top align=left bgcolor=#800000>
");
for(;$i>0;$i--){
// $result=mysql_query($sql);
$result = mysql_query("SELECT * FROM zclasslt",$db);
while($myrow=mysql_fetch_row($result)){
if($myrow[0]==$i){
if($myrow[5]==0){
$myrow[4]=htmlspecialchars($myrow[4]);
$myrow[4]=nl2br($myrow[4]);
echo"<table border=0 >n";
printf("
<tr><td bkcolor=800000><div align=left>
<table border=0 bordercolordark=#FFFFFF cellpadding=0 cellspacing=0 width=383>
<tr>
<td bgcolor=#000000><b><font face=黑体 size=4>%s<small><small><small><small>%s </small></small></small></small><a href=%s?id=%s>%s</a></font></b></td>
</tr>
</table>
</div></td></tr>",$myrow[1],$myrow[3],$PATH_INFO,$myrow[0],$myrow[2]);
echo"</table>";
}// if myrow[5]=0
else{
if($myrow[5]==1){
echo"<table border=0 >n";
printf("
<tr><td bkcolor=800000><div align=left>
<table border=0 bordercolordark=#FFFFFF cellpadding=0 cellspacing=0 width=383>
<tr>
<td bgcolor=#000000><b><font face=黑体 size=4>%s<small><small><small><small>%s </small></small></small></small><a href=%s?id=%s>%s</a></font></b></td>
</tr>
</table>
</div></td></tr>",$myrow[1],$myrow[3],$PATH_INFO,$myrow[0],$myrow[2]);
echo"</table>";
$result = mysql_query("SELECT * FROM zclasslt",$db);
$numrow=mysql_num_rows($result);
for($j=0;$j<$numrow;$j++){
if(mysql_result($result,$j,"rtitle")==$myrow[0]){
echo"<table border=0 >n";
printf("
<tr><td bkcolor=800000><div align=left>
<table border=0 bordercolordark=#FFFFFF cellpadding=0 cellspacing=0 width=383>
<tr>
<td bgcolor=#000000><b><font face=黑体 size=4 color=ffffff>%s<small><small><small><small>%s R:</small></small></small></small></font><font color=800000 face=黑体 size=4>%s</font></b></td>
</tr>
</table>
</div></td></tr>",mysql_result($result,$j,"name"),mysql_result($result,$j,"time"),mysql_result($result,$j,"title"));
echo"</table>";
}//mysql_result($result,alj
}//$j=$myrow[0];$j<$maxid;$j++
}//if myrow[5]=1;
}//////else
}//if myrow[0]==$i
}//for
}// while
}
} //if $submit
else if($id){
print("
<div align=left><left>
<table border=0 width=732 height=60 cellspacing=0 cellpadding=0
>
<tr>
<td width=349 height=60 valign=top align=left background=bubbles.jpg><div align=center><center><table
border=1 width=74 height=114 cellspacing=0 cellpadding=0 bgcolor=#800000>
<tr>
<td width=98 height=114 valign=top align=left><a href=index.php><img src=zclass2.jpg width=96
height=246 alt=垃圾制造></a></td>
<td width=394 height=114 valign=top align=right bgcolor=#800000><textarea
name=zclasslttextarea rows=12 cols=32></textarea><font face=黑体 size=4>标题</font>:<input type=text
name=zclasslttitle size=26><font face=黑体 size=4>姓名</font>:<input type=text name=zclassltname size=19> <input
type=submit name=submit value=回复>
<input type=hidden name=test value=1><input type=hidden name=testid value=$id></td>
</tr>
</table>
</center></div><img src=rubbish.jpg></td>
<td width=383 height=60 cellpadding=0 cellspacing=0 valign=top align=left bgcolor=#800000>
");
$result = mysql_query("SELECT * FROM zclasslt",$db);
while($myrow=mysql_fetch_row($result)){
if($myrow[0]==$id||$myrow[5]==$id){
$myrow[4]=htmlspecialchars($myrow[4]);
$myrow[4]=nl2br($myrow[4]);
echo"<table border=0 >n";
printf("
<tr>
<td>
<div align=left>
<table border=0 bordercolordark=#FFFFFF cellpadding=0 cellspacing=0 width=383>
<tr>
<td bgcolor=#000000><b><font face=黑体 size=4>%s</font></b></td>
</tr>
</table>
</div>
</td>
</tr>
<tr><td><div align=left>
<table border=0 bordercolordark=#FFFFFF cellpadding=0 cellspacing=0>
<tr>
<td ><b><font face=黑体 size=4>%s</font></b></td>
</tr>
</table>
</div>
</td></tr>
<tr><td bkcolor=800000><div align=left>
<table border=0 bordercolordark=#FFFFFF cellpadding=0 cellspacing=0 width=383>
<tr>
<td bgcolor=#000000><b><font face=黑体 size=4>%s <small><small>%s</small></small></font></b></td>
</tr>
</table>
</div></td></tr>",$myrow[2],$myrow[4],$myrow[1],$myrow[3]);
//echo"<br>";
echo"</table>";
}
}
}
else{
$result = mysql_query("SELECT * FROM zclasslt",$db);
$maxid=0;
while($myrow=mysql_fetch_array($result)){
if($maxid<$myrow["id"])
$maxid=$myrow["id"];
}
$i=$maxid;
print("
<div align=left><left>
<table border=0 width=732 height=60 cellspacing=0 cellpadding=0
>
<tr>
<td width=349 height=60 valign=top align=left background=bubbles.jpg><div align=center><center><table
border=1 width=74 height=114 cellspacing=0 cellpadding=0 bgcolor=#800000>
<tr>
<td width=98 height=114 valign=top align=left><a href=index.php><img src=zclass2.jpg width=96
height=246 alt=垃圾制造></a></td>
<td width=394 height=114 valign=top align=right bgcolor=#800000><textarea
name=zclasslttextarea rows=12 cols=32></textarea><font face=黑体 size=4>标题</font>:<input type=text
name=zclasslttitle size=26><font face=黑体 size=4>姓名</font>:<input type=text name=zclassltname size=19> <input
type=submit name=submit value=提交><input type=hidden name=test value=0></td>
</tr>
</table>
</center></div><img src=rubbish.jpg></td>
<td width=383 height=60 cellpadding=0 cellspacing=0 valign=top align=left bgcolor=#800000>
");
for(;$i>0;$i--){
$result=mysql_query($sql);
$result = mysql_query("SELECT * FROM zclasslt",$db);
while($myrow=mysql_fetch_row($result)){
if($myrow[0]==$i){
if($myrow[5]==0){
$myrow[4]=htmlspecialchars($myrow[4]);
$myrow[4]=nl2br($myrow[4]);
echo"<table border=0 >n";
printf("
<tr><td bkcolor=800000><div align=left>
<table border=0 bordercolordark=#FFFFFF cellpadding=0 cellspacing=0 width=383>
<tr>
<td bgcolor=#000000><b><font face=黑体 size=4>%s<small><small><small><small>%s </small></small></small></small><a href=%s?id=%s>%s</a></font></b></td>
</tr>
</table>
</div></td></tr>",$myrow[1],$myrow[3],$PATH_INFO,$myrow[0],$myrow[2]);
echo"</table>";
}// if myrow[5]=0
else{
if($myrow[5]==1){
echo"<table border=0 >n";
printf("
<tr><td bkcolor=800000><div align=left>
<table border=0 bordercolordark=#FFFFFF cellpadding=0 cellspacing=0 width=383>
<tr>
<td bgcolor=#000000><b><font face=黑体 size=4>%s<small><small><small><small>%s </small></small></small></small><a href=%s?id=%s>%s</a></font></b></td>
</tr>
</table>
</div></td></tr>",$myrow[1],$myrow[3],$PATH_INFO,$myrow[0],$myrow[2]);
echo"</table>";
$result = mysql_query("SELECT * FROM zclasslt",$db);
$numrow=mysql_num_rows($result);
for($j=0;$j<$numrow;$j++){
if(mysql_result($result,$j,"rtitle")==$myrow[0]){
echo"<table border=0 >n";
printf("
<tr><td bkcolor=800000><div align=left>
<table border=0 bordercolordark=#FFFFFF cellpadding=0 cellspacing=0 width=383>
<tr>
<td bgcolor=#000000><b><font face=黑体 size=4 color=ffffff>%s<small><small><small><small>%s R:</small></small></small></small></font><font color=800000 face=黑体 size=4>%s</font></b></td>
</tr>
</table>
</div></td></tr>",mysql_result($result,$j,"name"),mysql_result($result,$j,"time"),mysql_result($result,$j,"title"));
echo"</table>";
}//mysql_result($result,alj
}//$j=$myrow[0];$j<$maxid;$j++
}//if myrow[5]=1;
}//////else
}//if myrow[0]==$i
}//whie
}//for
}
?>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
php爱好 者站 http://www.phpfans.net php基础|php进阶|php模板.
程序的显示部分完全可以用*.inc包括,
数据库 zclasslt
/********
id int not null
name varcher(20)
title varcher(50)
note text
rtitle int
******/
运行结果可以去zclass.oso.com.cn/zclasslt.php
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Zclass论坛</title>
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
</head>
<body bgcolor="#000000" text="#FFFFFF" vlink=800000 alink=800000 link=800000>
<div align=left>
<table border=0 bordercolordark=#FFFFFF cellpadding=0 cellspacing=0 width=743
height=36>
<tr>
<td bgcolor=#800000 height=34 width=737><marquee
direction=left border=0><u><font face=黑体 color=#ffffff size=5>就等着我泡到500分吧</font><font size=1>Zclass.yeah.net</font></u></td>
</tr>
</table>
</div>
<form method=post action="<?echo $PATH_INFO;?>">
<?
$db=mysql_connect("localhost","root");
mysql_select_db("zclasslt",$db);
$result=mysql_query("SELECT * FROM zclasslt",$db);
if($submit){
$zclasslttime=date("y,m,d");
$result = mysql_query("SELECT * FROM zclasslt",$db);
while($myrow=mysql_fetch_array($result)){
$thetext=$myrow["note"];
}
if($zclasslttextarea==""||$zclasslttextarea==$thetext){
$error="<br> <font face=黑体 size=5>请</font><br> <font face=黑体 size=5>填</font><br> <font face=黑体 size=5>写</font><br> <font face=黑体 size=5>留</font><br> <font face=黑体 size=5>言</font>";
print( $error);}
else {
if($zclassltname=="")
{ $zclassltname="匿名";}
if($zclasslttitle==""){
$zclasslttitle="无题";
}
if($test){
$zclassltrtitle=$testid;
$sql="UPDATE zclasslt SET rtitle=1 WHERE ID=$testid";
$result=mysql_query($sql);
}else{$zclassltrtitle=$test;}
$sql="INSERT INTO zclasslt(name,title,note,time,rtitle)
VALUES('$zclassltname','$zclasslttitle','$zclasslttextarea','$zclasslttime','$zclassltrtitle')";
$result=mysql_query($sql);
$result = mysql_query("SELECT * FROM zclasslt",$db);
$maxid=0;
while($myrow=mysql_fetch_array($result)){
if($maxid<$myrow["id"])
$maxid=$myrow["id"];
}
$i=$maxid;
print("
<div align=left><left>
<table border=0 width=732 height=60 cellspacing=0 cellpadding=0
>
<tr>
<td width=349 height=60 valign=top align=left background=bubbles.jpg><div align=center><center><table
border=1 width=74 height=114 cellspacing=0 cellpadding=0 bgcolor=#800000>
<tr>
<td width=98 height=114 valign=top align=left><a href=index.php><img src=zclass2.jpg width=96
height=246 alt=垃圾制造></a></td>
<td width=394 height=114 valign=top align=right bgcolor=#800000><textarea
name=zclasslttextarea rows=12 cols=32></textarea><font face=黑体 size=4>标题</font>:<input type=text
name=zclasslttitle size=26><font face=黑体 size=4>姓名</font>:<input type=text name=zclassltname size=19> <input
type=submit name=submit value=提交><input type=hidden name=test value=0></td>
</tr>
</table>
</center></div><img src=rubbish.jpg></td>
<td width=383 height=60 cellpadding=0 cellspacing=0 valign=top align=left bgcolor=#800000>
");
for(;$i>0;$i--){
// $result=mysql_query($sql);
$result = mysql_query("SELECT * FROM zclasslt",$db);
while($myrow=mysql_fetch_row($result)){
if($myrow[0]==$i){
if($myrow[5]==0){
$myrow[4]=htmlspecialchars($myrow[4]);
$myrow[4]=nl2br($myrow[4]);
echo"<table border=0 >n";
printf("
<tr><td bkcolor=800000><div align=left>
<table border=0 bordercolordark=#FFFFFF cellpadding=0 cellspacing=0 width=383>
<tr>
<td bgcolor=#000000><b><font face=黑体 size=4>%s<small><small><small><small>%s </small></small></small></small><a href=%s?id=%s>%s</a></font></b></td>
</tr>
</table>
</div></td></tr>",$myrow[1],$myrow[3],$PATH_INFO,$myrow[0],$myrow[2]);
echo"</table>";
}// if myrow[5]=0
else{
if($myrow[5]==1){
echo"<table border=0 >n";
printf("
<tr><td bkcolor=800000><div align=left>
<table border=0 bordercolordark=#FFFFFF cellpadding=0 cellspacing=0 width=383>
<tr>
<td bgcolor=#000000><b><font face=黑体 size=4>%s<small><small><small><small>%s </small></small></small></small><a href=%s?id=%s>%s</a></font></b></td>
</tr>
</table>
</div></td></tr>",$myrow[1],$myrow[3],$PATH_INFO,$myrow[0],$myrow[2]);
echo"</table>";
$result = mysql_query("SELECT * FROM zclasslt",$db);
$numrow=mysql_num_rows($result);
for($j=0;$j<$numrow;$j++){
if(mysql_result($result,$j,"rtitle")==$myrow[0]){
echo"<table border=0 >n";
printf("
<tr><td bkcolor=800000><div align=left>
<table border=0 bordercolordark=#FFFFFF cellpadding=0 cellspacing=0 width=383>
<tr>
<td bgcolor=#000000><b><font face=黑体 size=4 color=ffffff>%s<small><small><small><small>%s R:</small></small></small></small></font><font color=800000 face=黑体 size=4>%s</font></b></td>
</tr>
</table>
</div></td></tr>",mysql_result($result,$j,"name"),mysql_result($result,$j,"time"),mysql_result($result,$j,"title"));
echo"</table>";
}//mysql_result($result,alj
}//$j=$myrow[0];$j<$maxid;$j++
}//if myrow[5]=1;
}//////else
}//if myrow[0]==$i
}//for
}// while
}
} //if $submit
else if($id){
print("
<div align=left><left>
<table border=0 width=732 height=60 cellspacing=0 cellpadding=0
>
<tr>
<td width=349 height=60 valign=top align=left background=bubbles.jpg><div align=center><center><table
border=1 width=74 height=114 cellspacing=0 cellpadding=0 bgcolor=#800000>
<tr>
<td width=98 height=114 valign=top align=left><a href=index.php><img src=zclass2.jpg width=96
height=246 alt=垃圾制造></a></td>
<td width=394 height=114 valign=top align=right bgcolor=#800000><textarea
name=zclasslttextarea rows=12 cols=32></textarea><font face=黑体 size=4>标题</font>:<input type=text
name=zclasslttitle size=26><font face=黑体 size=4>姓名</font>:<input type=text name=zclassltname size=19> <input
type=submit name=submit value=回复>
<input type=hidden name=test value=1><input type=hidden name=testid value=$id></td>
</tr>
</table>
</center></div><img src=rubbish.jpg></td>
<td width=383 height=60 cellpadding=0 cellspacing=0 valign=top align=left bgcolor=#800000>
");
$result = mysql_query("SELECT * FROM zclasslt",$db);
while($myrow=mysql_fetch_row($result)){
if($myrow[0]==$id||$myrow[5]==$id){
$myrow[4]=htmlspecialchars($myrow[4]);
$myrow[4]=nl2br($myrow[4]);
echo"<table border=0 >n";
printf("
<tr>
<td>
<div align=left>
<table border=0 bordercolordark=#FFFFFF cellpadding=0 cellspacing=0 width=383>
<tr>
<td bgcolor=#000000><b><font face=黑体 size=4>%s</font></b></td>
</tr>
</table>
</div>
</td>
</tr>
<tr><td><div align=left>
<table border=0 bordercolordark=#FFFFFF cellpadding=0 cellspacing=0>
<tr>
<td ><b><font face=黑体 size=4>%s</font></b></td>
</tr>
</table>
</div>
</td></tr>
<tr><td bkcolor=800000><div align=left>
<table border=0 bordercolordark=#FFFFFF cellpadding=0 cellspacing=0 width=383>
<tr>
<td bgcolor=#000000><b><font face=黑体 size=4>%s <small><small>%s</small></small></font></b></td>
</tr>
</table>
</div></td></tr>",$myrow[2],$myrow[4],$myrow[1],$myrow[3]);
//echo"<br>";
echo"</table>";
}
}
}
else{
$result = mysql_query("SELECT * FROM zclasslt",$db);
$maxid=0;
while($myrow=mysql_fetch_array($result)){
if($maxid<$myrow["id"])
$maxid=$myrow["id"];
}
$i=$maxid;
print("
<div align=left><left>
<table border=0 width=732 height=60 cellspacing=0 cellpadding=0
>
<tr>
<td width=349 height=60 valign=top align=left background=bubbles.jpg><div align=center><center><table
border=1 width=74 height=114 cellspacing=0 cellpadding=0 bgcolor=#800000>
<tr>
<td width=98 height=114 valign=top align=left><a href=index.php><img src=zclass2.jpg width=96
height=246 alt=垃圾制造></a></td>
<td width=394 height=114 valign=top align=right bgcolor=#800000><textarea
name=zclasslttextarea rows=12 cols=32></textarea><font face=黑体 size=4>标题</font>:<input type=text
name=zclasslttitle size=26><font face=黑体 size=4>姓名</font>:<input type=text name=zclassltname size=19> <input
type=submit name=submit value=提交><input type=hidden name=test value=0></td>
</tr>
</table>
</center></div><img src=rubbish.jpg></td>
<td width=383 height=60 cellpadding=0 cellspacing=0 valign=top align=left bgcolor=#800000>
");
for(;$i>0;$i--){
$result=mysql_query($sql);
$result = mysql_query("SELECT * FROM zclasslt",$db);
while($myrow=mysql_fetch_row($result)){
if($myrow[0]==$i){
if($myrow[5]==0){
$myrow[4]=htmlspecialchars($myrow[4]);
$myrow[4]=nl2br($myrow[4]);
echo"<table border=0 >n";
printf("
<tr><td bkcolor=800000><div align=left>
<table border=0 bordercolordark=#FFFFFF cellpadding=0 cellspacing=0 width=383>
<tr>
<td bgcolor=#000000><b><font face=黑体 size=4>%s<small><small><small><small>%s </small></small></small></small><a href=%s?id=%s>%s</a></font></b></td>
</tr>
</table>
</div></td></tr>",$myrow[1],$myrow[3],$PATH_INFO,$myrow[0],$myrow[2]);
echo"</table>";
}// if myrow[5]=0
else{
if($myrow[5]==1){
echo"<table border=0 >n";
printf("
<tr><td bkcolor=800000><div align=left>
<table border=0 bordercolordark=#FFFFFF cellpadding=0 cellspacing=0 width=383>
<tr>
<td bgcolor=#000000><b><font face=黑体 size=4>%s<small><small><small><small>%s </small></small></small></small><a href=%s?id=%s>%s</a></font></b></td>
</tr>
</table>
</div></td></tr>",$myrow[1],$myrow[3],$PATH_INFO,$myrow[0],$myrow[2]);
echo"</table>";
$result = mysql_query("SELECT * FROM zclasslt",$db);
$numrow=mysql_num_rows($result);
for($j=0;$j<$numrow;$j++){
if(mysql_result($result,$j,"rtitle")==$myrow[0]){
echo"<table border=0 >n";
printf("
<tr><td bkcolor=800000><div align=left>
<table border=0 bordercolordark=#FFFFFF cellpadding=0 cellspacing=0 width=383>
<tr>
<td bgcolor=#000000><b><font face=黑体 size=4 color=ffffff>%s<small><small><small><small>%s R:</small></small></small></small></font><font color=800000 face=黑体 size=4>%s</font></b></td>
</tr>
</table>
</div></td></tr>",mysql_result($result,$j,"name"),mysql_result($result,$j,"time"),mysql_result($result,$j,"title"));
echo"</table>";
}//mysql_result($result,alj
}//$j=$myrow[0];$j<$maxid;$j++
}//if myrow[5]=1;
}//////else
}//if myrow[0]==$i
}//whie
}//for
}
?>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
php爱好 者站 http://www.phpfans.net php基础|php进阶|php模板.
相关阅读 更多 +