当前位置:Gxlcms > PHP教程 > 树状BBS设计参考_PHP

树状BBS设计参考_PHP

时间:2021-07-01 10:21:17 帮助过:24人阅读

简单 BBS 系统 需 MySQL。
以下是BBS的表结构,用以下的语句就可以建立:

CREATE TABLE bbsMessage
(
ID INT NOT NULL AUTO_INCREMENT,
Title VARCHAR(64),
Poster VARCHAR(64),
Created DATETIME,
Parent INT,
Body BLOB,
PRIMARY KEY(ID)
);



This is my BBS


/******************************************************
BBS v1.0
编码: PHP 3
作者: Leon Atkinson < leon.atkinson@clearink.com >

简单 BBS 系统 需 MySQL。
以下是BBS的表结构,用以下的语句就可以建立:

CREATE TABLE bbsMessage
(
ID INT NOT NULL AUTO_INCREMENT,
Title VARCHAR(64),
Poster VARCHAR(64),
Created DATETIME,
Parent INT,
Body BLOB,
PRIMARY KEY(ID)
);

*******************************************************/

printf( "

Leon's BBS

\n");

/* 设置数据库 */
mysql_pconnect( "www.yoursever.com", "httpd");
$Database = "yourdb";

/****************************************************************
一个吐出派生信息的递归函数
****************************************************************/
function showMessages($parentID)
{
global $Database;

$dateToUse = Date( "U");

echo "

    \n";

    /* 显示所有的类别 */
    $Query = "SELECT * FROM bbsMessage ";
    $Query = $Query . "WHERE Parent=$parentID ";
    $Query = $Query . "ORDER BY Created ";

    $result = mysql($Database,$Query);
    $numRows = mysql_NumRows($result);
    $RowCount = 0;
    while($RowCount < $numRows)
    {
    $messageID = mysql_result($result,$RowCount, "ID");
    $messageTitle = mysql_result($result,$RowCount, "Title");
    $messageCreated = mysql_result($result,$RowCount, "Created");
    $messageParent = mysql_result($result,$RowCount, "Parent");

    /*显示一行是什么类别的信息 */
    printf( "

  • ($messageCreated) $messageTitle
    \n");

    /* 调用 getWingContents 以得到它的分支 */
    showMessages($messageID);

    $RowCount++;
    }

    echo "

\n";
}

/****************************************************************
输出一个提交新信息的表单,并在其中预置一个父ID
****************************************************************/
function postForm($parentID, $useTitle)
{
printf( "\n");

}

/******************************************************
执行动作
******************************************************/
if($ACTION != "")
{
if($ACTION == "POST")
{
$inputTitle = ereg_replace( "'", "''", $inputTitle);
$inputBody = ereg_replace( "'", "''", $inputBody);

$Query = "INSERT INTO bbsMessage ";
$Query .= "VALUES(0, '$inputTitle', ";
$Query .= "'$inputPoster', ";
$Query .= "now(), $inputParent, ";
$Query .= "'$inputBody')";

$result = mysql($Database,$Query);


}

}


/******************************************************
显示信息或者是显示信息列表
******************************************************/
if($messageID > 0)
{
$Query = "SELECT * FROM bbsMessage ";
$Query = $Query . "WHERE ID=$messageID ";

$result = mysql($Database,$Query);
$numRows = mysql_NumRows($result);
$RowCount = 0;
if($RowCount < $numRows)
{
$messageID = mysql_result($result,$RowCount, "ID");
$messageTitle = mysql_result($result,$RowCount, "Title");
$messagePoster = mysql_result($result,$RowCount, "Poster");
$messageCreated = mysql_result($result,$RowCount, "Created");
$messageParent = mysql_result($result,$RowCount, "Parent");
$messageBody = mysql_result($result,$RowCount, "Body");

printf( "

\n");
printf( "\n");
printf( "\n");
printf( "\n");
printf( "\n");
printf( "
Title$messageTitle
Poster$messagePoster
Posted$messageCreated
$messageBody
\n");

postForm($messageID, "RE: $messageTitle");

}

echo "List of Messages
";

}
else
{
printf( "

List of Messages

\n");

/* 调用递归函数*/
showMessages(0);

postForm(0, "");

}

?>


人气教程排行