A concise multi-level Forum _php Foundation

Source: Internet
Author: User
This forum uses a total of less than 200 lines of code, execution speed is very fast. Running example in: Http://www.hnpts.ha.cn/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 | |
+-------+--------------+------+-----+---------+----------------+

index.php:

<style type= "Text/css" >

<!--
. unnamed1 {font-size:9pt; font-family: "XXFarEastFont-Arial"}
. unnamed1 A {COLOR: #000088; font-size:9pt; Text-decoration:none; Text-transform:none; font-family: "Song Body"}
. unnamed1 a:hover {COLOR: #880000; font-size:9pt; Text-decoration:underline overline; Font-family: "Italics _gb2312"}
. unnamed2 {font-size:12px; color: #9933FF}

-->

</style>
<body bgcolor= "#FFFFFF" text= "#000000" link= "#000066" vlink= "#0000CC" alink= "#000099" >
$m =mysql_connect ("localhost", "xxxx", "xxxx");
mysql_select_db ("xxxx", $m);
?>

<?if ($FL = = "") $FL = 1;
$HF _fl= $FL;
$q = "SELECT * from Yxforum where id=". $FL;
$MR =mysql_query ($q, $m);
$ra =mysql_fetch_row ($MR);
?>
<p Align=center><b><?print ($ra [2]);? ></b><br>
<?if ($FL!=1) {
?>
<small><?printf ("(<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 subject:</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; $p 1= $p *15; /* Skip the specified number of pages in the corresponding line * *
while ($i < $p 1)
{$i + +;
$ra =mysql_fetch_row ($MR);
if (! $ra) break;


?>
<center>
<table border=0 width=732 class= "Unnamed1" >
&LT;TR align= "center" valign= "Top" bgcolor= "#FFFFCC" >
&LT;TD width= "186" > Latest response time
&LT;TD width= "A" > Published person
&LT;TD width= "414" > Theme
&LT;TD width= > Response number
</tr>
?
$x [0]= "FFFFCC"; $x [1]= "deefff"; $i = 1;
while ($RA)/* Displays the current theme * *
{$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=index.php?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=index.php method=get name=f0 onsubmit= "document. F0.p.value--;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=index.php?fl=%s> home </a>", $HF _FL);
printf ("<a href=index.php?fl=%s&p=%d> prev </a>", $HF _fl, $p-1);}
if ($ra) {printf ("<a href=index.php?fl=%s&p=%d> next Page </a>", $HF _fl, $p + 1);
printf ("<a href=index.php?fl=%s&p=%d> last </a>", $HF _fl, $pages-1);}
?> Specify <input type=text size=2 name=p> page
</span>
<span class=unnamed1>
<?if ($HF _fl!=1) {printf ("<br><a href=index.php?fl=%s> upper Level </a>", $lastid);
Print ("<a href=index.php> superlative </a><br>");}
?>
</form><center>
<table width=80% bgcolor= #eeeeff ><tr><td class=unnamed1>
<?print ($FL ==1)? " Add a new post: ":" Response: ");? >
<form action= "addnew.php" Method=post name= "F1" >
Name:
<input type= "text" name= "nm" size= ">"
<br>
Email:
<input type= "text" name= "em" size= ">"
<br>
Title (required):
<input type= "text" Name= "tt" size= "<?if"!=1 ($FL value=) print ("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= "rows=" ></textarea>
<input type= "Submit" name= "Submission" value= "submitted" >
</form>
</tr></table></center>
<center> Forum Program version 0.25 design tools:php+mysql<br>
<a href=mailto:fhl@cgi.hnpts.ha.cn> Gu Qitzing Sword </a> production <br><a href=http://www.fhlfox.dhs.org> Xiaoyao Flying Fox Multimedia Workshop </a> </center>
</span>
</body>



addnew.php:

$m =mysql_connect ("localhost", "xxx", "xxxxx");
mysql_select_db ("xxxxx", $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 = "Nameless Treasure";
if ($em = = "") {$nm. = "<--is a rookie without mail"; $em = "No";}
$err =strlen ($TT) *strlen ($ZW);
if ($err ==0)
$msg = "<font color=red> don't be lazy!" Fill out the form before submitting it later. </font> ";
else {$q = "insert into Yxforum (dt,tp,ct,fl,ip,un,em,num) values"
." (Now (), "". $tt. "," ". $zw." "," ". $fl.", "". $REMOTE _addr. "", "". $nm. "", "" $em
mysql_query ($q, $m);

$q = "Select Num,fl from Yxforum where id=". $FL;
$FL _a= $FL;
do {$mr =mysql_query ($q, $m);
$ra =mysql_fetch_row ($MR);
$num = $ra [0]+1;
$q = "Update yxforum set Dt=now (), num=". $num. "Where id=". $FL;
$FL = $ra [1];
mysql_query ($q, $m);
$q = "Select Num,fl from Yxforum where id=". $FL;
while ($FL >0);


$msg = "<font color=green> your opinion has been successfully submitted!" </font> ";
}
?>
<script language= "Javascript" >
function Go ()
{document.location= "index.php?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=index.php?fl=<?print ($FL _a); >&p=<?print ($p)?>> </a>
</body>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.