I wrote a php+mysql easy to implement the forum in the grading + pagination display routines! (Very detailed Oh!) Although efficiency is not the best, it is not ...
mysql| Pagination |
/* Store the table structure of the posts------------------------------------------------------
CREATE TABLE Bbsrow (
bbsrow_id Int (6) NOT NULL auto_increment,//posting ID number
Bbsrow_auth varchar NOT NULL,//Post author
Bbsrow_parentid Int (6),//The Father Post ID number of the posting, if the initial sticker is blank
Bbsrow_title varchar NOT NULL,//posts title
Bbsrow_returncount Int (3),//Post number of replies, if no replies are empty
Primary KEY (BBSROW_ID)
);
-----------------------------------------------------------------------------*/
A recursive function that shows the son's post--------------------------------------------------
function Showchildren ($parent _id) {
Global $connect _id;
$query = "SELECT * from Bbsrow where bbsrow_parentid= '". $parent _id. "'";
$result _top=mysql_query ($query, $connect _id);
echo "<ul>\n";
while ($myrow _child=mysql_fetch_row ($result _top)) {
echo "<li>";
echo $myrow _child[0];
echo $myrow _child[1];
echo $myrow _child[2];
echo $myrow _child[3];
Echo $myrow _child[4]. "\ n";
If the reply to the number of stickers is not empty, it means that there is a son posted, continue to show son stickers
if ($myrow _child[4]!= ') {
Showchildren ($myrow _child[0]);
}
}
echo "</ul>";
}
//----------------------------------------------------------------------
Connect the database and put all the starter stickers in the $mainrow array----------------------------
$connect _id=mysql_connect ("localhost", "Test", "test") or Die ("Unable to connect to database");
mysql_select_db ("BBS") or Die ("Cannot select Database");
$query = "SELECT * from Bbsrow where bbsrow_parentid= '";
$result =mysql_query ($query, $connect _id);
echo "<ul>\n";
for ($i = $start; $i < $end; $i + +) {
echo "<li>\n";
echo $mainrow [$i][0];
echo $mainrow [$i][1];
echo $mainrow [$i][2];
echo $mainrow [$i][3];
echo $mainrow [$i][4]. "\ n";
If the reply to the number of stickers is not empty, it means that there is a son posted, continue to show son stickers
if ($mainrow [$i][4]!= ') {
Showchildren ($mainrow [$i][0]);
}
}
echo "</ul>\n";
----------------------------------------------------------------------? >
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.