/*Table structure for storing posts--------------------------------------------- ------------
create table bbsrow(
bbsrow_id int(6) not null auto_increment, //Post ID number
bbsrow_auth varchar(20) not null, // Post author
bbsrow_parentid int(6), //The post's father's post ID number, if it is the first post, it will be empty
bbsrow_title varchar(200) not null, //Post title
bbsrow_returncount int(3), //The number of replies to the post, if there is no reply, it will be empty
primary key (bbsrow_id)
);
------------- -------------------------------------------------- ---------------*/
//Display the recursive function posted by my son----------------------- -----------------------------
function showchildren($parent_id){
global $connect_id;
$query= "select * from bbsrow where bbsrow_parentid='" . $parent_id . "'";
$result_top=mysql_query($query,$connect_id);
echo "
n";
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] . "n";
//If the number of reply posts is not empty, it means there are son posts and continue to display son posts
if ($myrow_child[4]!=''){
showchildren($myrow_child[0]);
}
}
echo "
";
}
/ /------------------------------------------------- ---------------------
//Connect to the database and put all first posts into the $mainrow array---------- ------------------
$connect_id=mysql_connect("localhost","test","test") or die("Unable to connect to database");
mysql_select_db("bbs") or die("Unable to 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];
$i++;
}