This forum uses less than 200 lines of code in total, and the execution speed is quite fast. Running example is: /forum
MYSQL database: yxforum
+-------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+----------------+
| id | int(11) | | PRI | 0 | auto_increment |
| dt | datetime | YES | | NULL | |
| tp | varchar(255) | YES | | NULL | |
| ct | text | YES | | NULL | |
| fl | int(11) | YES | | NULL | |
| ip | varchar(20) | YES | | NULL | |
| un | varchar(50) | YES | | NULL | |
| em | varchar(60) | YES | | NULL | |
| num | int(11) | YES | | NULL | |
+-------+--------------+------+-----+---------+----------------+
:
<html>
<head>
<style type="text/css">
<!--
.unnamed1 { font-size: 9pt; font-family: "Stick"}
.unnamed1 A {COLOR: #000088; FONT-SIZE: 9pt; TEXT-DECORATION: none; TEXT-TRANSFORM: none; font-family: "Stick"}
.unnamed1 A:hover {COLOR: #880000; FONT-SIZE: 9pt; TEXT-DECORATION: underline overline; font-family: "KaiTi_GB2312"}
.unnamed2 { font-size: 12px; color: #9933FF}
-->
</style>
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#000066" vlink="#0000CC" alink="#000099">
<?$m=mysql_connect("localhost","××××","××××");
mysql_select_db("××××",$m);
?>
<?if ($fl=="") $fl=1;
$hf_fl=$fl;
$q="select * from yxforum where (<a href=mailto:%s>%s</a>) ",$ra[7],$ra[6]);?>
</small></p>
<?$alltt=$ra[2];
$lastid=$ra[4];
print("<center><table width=90% border=1><tr><td bgcolor=#dddddd class=unnamed1>".$ra[3]."</tr></table></center>");
print("<br><small>Follow the topic:</small>");
}
$q="select * from yxforum where fl=".$fl." order by dt desc";
if ($p=="") $p=0;
$mr=mysql_query($q,$m);
$f=mysql_num_fields($mr);
$ra=mysql_fetch_row($mr);
$i=0; $p1=$p*15; /*Skip the row corresponding to the specified number of pages*/
while ($i<$p1)
{$i++;
$ra=mysql_fetch_row($mr);
if (! $ra) break;}
?>
<center>
<table border=0 width=732 class="unnamed1">
<tr align="center" valign="top" bgcolor="#FFFFCC">
<td width="186" >Latest response time
Published by
<td width="414">Theme
<td width="44">Response count
</tr>
<?
$x[0]="ffffcc";$x[1]="DEEFFF";$i=1;
while ($ra) /*Show the current topic*/
{$ys_c=$i%2;
print("<tr height=12 bgcolor=#".$x[$ys_c]."><td align=center>".$ra[1]);
print("<td align=center><a href=mailto:".$ra[7].">".$ra[6]."</a>");
print("<td>");
printf("<a href=?fl=%s>%s</a>",$ra[0],$ra[2]);
print("<td align=center>".$ra[8]);
print("</tr>");
$ra=mysql_fetch_row($mr);
$i++;
if ($i>15) break;
}
?>
</table></center>
<form action= method=get name=F0 onsubmit="document.--;return true;">
<span class=unnamed1>
<?
$alllines=mysql_affected_rows($m);
$pages=$alllines/15;
if ($pages-intval($pages)!=0) $pages=intval($pages)+1;
else $pages=intval($pages);
print("Total".$pages."page".($p+1)."page ");
if ($p>0) {printf("<a href=?fl=%s>Home</a> ",$hf_fl);
printf("<a href=?fl=%s&p=%d>Previous page</a> ",$hf_fl,$p-1);}
if ($ra) {printf("<a href=?fl=%s&p=%d>Next page</a> ",$hf_fl,$p+1);
printf("<a href=?fl=%s&p=%d>Last Page</a> ",$hf_fl,$pages-1);}
?>Specify the <input type=text size=2 name=p> page
</span>
<span class=unnamed1>
<?if ($hf_fl!=1) {printf("<br><a href=?fl=%s>Previous level</a> ",$lastid);
print("<a href=>The highest</a><br>");}
?>
</form><center>
<table width=80% bgcolor=#eeeeff><tr><td class=unnamed1>
<?print(($fl==1)?"Add a new post: ":"Response: ");?>
<form action="" method=post name="F1">
Name:
<input type="text" name="nm" size="15">
<br>
Email:
<input type="text" name="em" size="45">
<br>
Title (required):
<input type="text" name="tt" size="45" <?if ($fl!=1) print("value=Reply: ".$alltt);?> > >
<input type=hidden name="fl" value="<?print($hf_fl);?>">
<input type=hidden name="p" value="<?print($p);?>">
<br>
Text (required): <br>
<textarea name="zw" cols="50" rows="10"></textarea>
<input type="submit" name="Submit" value="Submit">
</form>
</tr></table></center>
<hr>
<center>Personal forum program version 0.25 Design tool: PHP+MYSQL<br>
<a href=mailto:fhl@>Gu Yue Qingjian</a> Production<br><a href=>Xiaoyao Feihu Multimedia Workshop</a> 2000 </center>
</span>
</body>
</html>
:
<?$m=mysql_connect("localhost","×××","×××××");
mysql_select_db("×××××",$m);
$zw=ereg_replace("<","<",$zw);
$zw=ereg_replace(">",">",$zw);
$zw=ereg_replace("n","<br>",$zw);
$zw=ereg_replace(" "," ",$zw);
$tt=ereg_replace("<","<",$tt);
$tt=ereg_replace(">",">",$tt);
if ($nm=="") $nm="Not Named Treasure";
if ($em=="") {$nm.="<-- Is a noob without MAIL";$em="No";}
$err=strlen($tt)*strlen($zw);
if ($err==0)
$msg="<font color=red>Don't be lazy! It's not too late to fill out the form and submit it.</font>";
else {$q="insert into yxforum (dt,tp,ct,fl,ip,un,em,num) values"
."(now(),"".$tt."","".$zw."",".$fl.","".$REMOTE_ADDR."","".$nm."","".$em."",0)";
mysql_query($q,$m);
$q="select num,fl from yxforum where update yxforum set dt=now(),num=".$num." where select num,fl from yxforum where <font color=green>Your comment has been submitted successfully!</font>";
}
?>
<html>
<head>
<script language="Javascript">
function go()
{="?fl=<?print($fl_a);?>&p=<?print($p)?>";
}
</script>
<body onload="setTimeout('go()',3000);">
<?print($msg);?><br>
The system will automatically return after 3 seconds. If you cannot return or you are anxious, please press <a href=?fl=<?print($fl_a);?>&p=<?print($p)?>>here</a>
</body>
MYSQL database: yxforum
+-------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+----------------+
| id | int(11) | | PRI | 0 | auto_increment |
| dt | datetime | YES | | NULL | |
| tp | varchar(255) | YES | | NULL | |
| ct | text | YES | | NULL | |
| fl | int(11) | YES | | NULL | |
| ip | varchar(20) | YES | | NULL | |
| un | varchar(50) | YES | | NULL | |
| em | varchar(60) | YES | | NULL | |
| num | int(11) | YES | | NULL | |
+-------+--------------+------+-----+---------+----------------+
:
<html>
<head>
<style type="text/css">
<!--
.unnamed1 { font-size: 9pt; font-family: "Stick"}
.unnamed1 A {COLOR: #000088; FONT-SIZE: 9pt; TEXT-DECORATION: none; TEXT-TRANSFORM: none; font-family: "Stick"}
.unnamed1 A:hover {COLOR: #880000; FONT-SIZE: 9pt; TEXT-DECORATION: underline overline; font-family: "KaiTi_GB2312"}
.unnamed2 { font-size: 12px; color: #9933FF}
-->
</style>
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#000066" vlink="#0000CC" alink="#000099">
<?$m=mysql_connect("localhost","××××","××××");
mysql_select_db("××××",$m);
?>
<?if ($fl=="") $fl=1;
$hf_fl=$fl;
$q="select * from yxforum where (<a href=mailto:%s>%s</a>) ",$ra[7],$ra[6]);?>
</small></p>
<?$alltt=$ra[2];
$lastid=$ra[4];
print("<center><table width=90% border=1><tr><td bgcolor=#dddddd class=unnamed1>".$ra[3]."</tr></table></center>");
print("<br><small>Follow the topic:</small>");
}
$q="select * from yxforum where fl=".$fl." order by dt desc";
if ($p=="") $p=0;
$mr=mysql_query($q,$m);
$f=mysql_num_fields($mr);
$ra=mysql_fetch_row($mr);
$i=0; $p1=$p*15; /*Skip the row corresponding to the specified number of pages*/
while ($i<$p1)
{$i++;
$ra=mysql_fetch_row($mr);
if (! $ra) break;}
?>
<center>
<table border=0 width=732 class="unnamed1">
<tr align="center" valign="top" bgcolor="#FFFFCC">
<td width="186" >Latest response time
Published by
<td width="414">Theme
<td width="44">Response count
</tr>
<?
$x[0]="ffffcc";$x[1]="DEEFFF";$i=1;
while ($ra) /*Show the current topic*/
{$ys_c=$i%2;
print("<tr height=12 bgcolor=#".$x[$ys_c]."><td align=center>".$ra[1]);
print("<td align=center><a href=mailto:".$ra[7].">".$ra[6]."</a>");
print("<td>");
printf("<a href=?fl=%s>%s</a>",$ra[0],$ra[2]);
print("<td align=center>".$ra[8]);
print("</tr>");
$ra=mysql_fetch_row($mr);
$i++;
if ($i>15) break;
}
?>
</table></center>
<form action= method=get name=F0 onsubmit="document.--;return true;">
<span class=unnamed1>
<?
$alllines=mysql_affected_rows($m);
$pages=$alllines/15;
if ($pages-intval($pages)!=0) $pages=intval($pages)+1;
else $pages=intval($pages);
print("Total".$pages."page".($p+1)."page ");
if ($p>0) {printf("<a href=?fl=%s>Home</a> ",$hf_fl);
printf("<a href=?fl=%s&p=%d>Previous page</a> ",$hf_fl,$p-1);}
if ($ra) {printf("<a href=?fl=%s&p=%d>Next page</a> ",$hf_fl,$p+1);
printf("<a href=?fl=%s&p=%d>Last Page</a> ",$hf_fl,$pages-1);}
?>Specify the <input type=text size=2 name=p> page
</span>
<span class=unnamed1>
<?if ($hf_fl!=1) {printf("<br><a href=?fl=%s>Previous level</a> ",$lastid);
print("<a href=>The highest</a><br>");}
?>
</form><center>
<table width=80% bgcolor=#eeeeff><tr><td class=unnamed1>
<?print(($fl==1)?"Add a new post: ":"Response: ");?>
<form action="" method=post name="F1">
Name:
<input type="text" name="nm" size="15">
<br>
Email:
<input type="text" name="em" size="45">
<br>
Title (required):
<input type="text" name="tt" size="45" <?if ($fl!=1) print("value=Reply: ".$alltt);?> > >
<input type=hidden name="fl" value="<?print($hf_fl);?>">
<input type=hidden name="p" value="<?print($p);?>">
<br>
Text (required): <br>
<textarea name="zw" cols="50" rows="10"></textarea>
<input type="submit" name="Submit" value="Submit">
</form>
</tr></table></center>
<hr>
<center>Personal forum program version 0.25 Design tool: PHP+MYSQL<br>
<a href=mailto:fhl@>Gu Yue Qingjian</a> Production<br><a href=>Xiaoyao Feihu Multimedia Workshop</a> 2000 </center>
</span>
</body>
</html>
:
<?$m=mysql_connect("localhost","×××","×××××");
mysql_select_db("×××××",$m);
$zw=ereg_replace("<","<",$zw);
$zw=ereg_replace(">",">",$zw);
$zw=ereg_replace("n","<br>",$zw);
$zw=ereg_replace(" "," ",$zw);
$tt=ereg_replace("<","<",$tt);
$tt=ereg_replace(">",">",$tt);
if ($nm=="") $nm="Not Named Treasure";
if ($em=="") {$nm.="<-- Is a noob without MAIL";$em="No";}
$err=strlen($tt)*strlen($zw);
if ($err==0)
$msg="<font color=red>Don't be lazy! It's not too late to fill out the form and submit it.</font>";
else {$q="insert into yxforum (dt,tp,ct,fl,ip,un,em,num) values"
."(now(),"".$tt."","".$zw."",".$fl.","".$REMOTE_ADDR."","".$nm."","".$em."",0)";
mysql_query($q,$m);
$q="select num,fl from yxforum where update yxforum set dt=now(),num=".$num." where select num,fl from yxforum where <font color=green>Your comment has been submitted successfully!</font>";
}
?>
<html>
<head>
<script language="Javascript">
function go()
{="?fl=<?print($fl_a);?>&p=<?print($p)?>";
}
</script>
<body onload="setTimeout('go()',3000);">
<?print($msg);?><br>
The system will automatically return after 3 seconds. If you cannot return or you are anxious, please press <a href=?fl=<?print($fl_a);?>&p=<?print($p)?>>here</a>
</body>