Use Php+mysql to achieve the forum's grading + pagination display _php tutorial

Source: Internet
Author: User
/* Table structure to store posts------------------------------------------------------
CREATE TABLE Bbsrow (
bbsrow_id Int (6) NOT NULL auto_increment,//posting ID number
Bbsrow_auth varchar () not NULL,//author of posts
Bbsrow_parentid Int (6),//Post ID number of the father posts, such as the first sticker is empty
Bbsrow_title varchar ($) NOT NULL,//Post title
Bbsrow_returncount Int (3),//Post number of replies, if no huitie is empty
Primary KEY (BBSROW_ID)
);
-----------------------------------------------------------------------------*/
Shows the recursive function of 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 "
      ";
      while ($myrow _child=mysql_fetch_row ($result _top)) {
      echo "
    • ";
      echo $myrow _child[0];
      echo $myrow _child[1];
      echo $myrow _child[2];
      echo $myrow _child[3];
      Echo $myrow _child[4]. "";
      If the number of replies is not empty, then there is a son paste, continue to show the son posted
      if ($myrow _child[4]!= ") {
      Showchildren ($myrow _child[0]);
      }
      }
      echo "
";
}
//----------------------------------------------------------------------
Connect to the database and place all the initial stickers into 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);
$i = 0;
while ($myrow =mysql_fetch_row ($result)) {
$mainrow [$i][0]= $myrow [0];
$mainrow [$i][1]= $myrow [1];
$mainrow [$i][2]= $myrow [2];
$mainrow [$i][3]= $myrow [3];
$mainrow [$i][4]= $myrow [4];

http://www.bkjia.com/PHPjc/631062.html www.bkjia.com true http://www.bkjia.com/PHPjc/631062.html techarticle */* table structure that holds posts------------------------------------------------------create table Bbsrow (bbsrow_id int (6) NOT NULL Auto_increment,//posts ID number Bbsrow_auth varchar (2 ...

  • Related Article

    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.