树状BBS设计参考
时间:2005-08-05 来源:manbuzhe0301
简单 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 系统 需 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
");
/* 设置数据库 */
mysql_pconnect( "
www.yoursever.com
", "httpd");
$Database = "yourdb";
/****************************************************************
一个吐出派生信息的递归函数
****************************************************************/
function showMessages($parentID)
{
global $Database;
$dateToUse = Date( "U");
echo "
";
/* 显示所有的类别 */
$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 ($messageCreated) $messageTitle
");
/* 调用 getWingContents 以得到它的分支 */
showMessages($messageID);
$RowCount++;
}
echo "
";
}
/****************************************************************
输出一个提交新信息的表单,并在其中预置一个父ID
****************************************************************/
function postForm($parentID, $useTitle)
{
printf( "
");
printf( "");
printf( "");
printf( "
");
printf( "Title");
printf( "
");
printf( "Poster");
printf( "
");
printf( "");
printf( "
");
printf( "
");
printf( "
");
printf( "
");
}
/******************************************************
执行动作
******************************************************/
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
");
printf( "Title$messageTitle
");
printf( "Poster$messagePoster
");
printf( "Posted$messageCreated
");
printf( "$messageBody
");
printf( "
");
postForm($messageID, "RE: $messageTitle");
}
echo "List of Messages
";
}
else
{
printf( "List of Messages
");
/* 调用递归函数*/
showMessages(0);
postForm(0, "");
}
?>
以下是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 系统 需 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
");
/* 设置数据库 */
mysql_pconnect( "
www.yoursever.com
", "httpd");
$Database = "yourdb";
/****************************************************************
一个吐出派生信息的递归函数
****************************************************************/
function showMessages($parentID)
{
global $Database;
$dateToUse = Date( "U");
echo "
";
/* 显示所有的类别 */
$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 ($messageCreated) $messageTitle
");
/* 调用 getWingContents 以得到它的分支 */
showMessages($messageID);
$RowCount++;
}
echo "
";
}
/****************************************************************
输出一个提交新信息的表单,并在其中预置一个父ID
****************************************************************/
function postForm($parentID, $useTitle)
{
printf( "
");
printf( "");
printf( "");
printf( "
");
printf( "Title");
printf( "
");
printf( "Poster");
printf( "
");
printf( "");
printf( "
");
printf( "
");
printf( "
");
printf( "
");
}
/******************************************************
执行动作
******************************************************/
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
");
printf( "Title$messageTitle
");
printf( "Poster$messagePoster
");
printf( "Posted$messageCreated
");
printf( "$messageBody
");
printf( "
");
postForm($messageID, "RE: $messageTitle");
}
echo "List of Messages
";
}
else
{
printf( "List of Messages
");
/* 调用递归函数*/
showMessages(0);
postForm(0, "");
}
?>
相关阅读 更多 +