最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
用PHP+MYSQL 实现论坛里的分级+分页显示
时间:2022-07-02 09:42:08 编辑:袖梨 来源:一聚教程网
/*存放贴子的表结构------------------------------------------------------
create table bbsrow(
bbsrow_id int(6) not null auto_increment, //贴子ID号
bbsrow_auth varchar(20) not null, //贴子作者
bbsrow_parentid int(6), //贴子的父亲贴子ID号,如为首发贴则为空
bbsrow_title varchar(200) not null, //贴子标题
bbsrow_returncount int(3), //贴子的回复贴数,如果没有回贴则为空
primary key (bbsrow_id)
);
-----------------------------------------------------------------------------*/
//显示儿子贴的递归函数--------------------------------------------------
function showchildren($parent_id){
global $connect_id;
$query="select * from bbsrow where bbsrow_parentid='" . $parent_id . "'";
$result_top=mysql_query($query,$connect_id);
echo "
-
";
- ";
echo $myrow_child[0];
echo $myrow_child[1];
echo $myrow_child[2];
echo $myrow_child[3];
echo $myrow_child[4] . " ";
//如果回复贴数不为空,则表示有儿子贴,继续显示儿子贴
if($myrow_child[4]!=''){
showchildren($myrow_child[0]);
}
}
echo "
while($myrow_child=mysql_fetch_row($result_top)){
echo "
}
//----------------------------------------------------------------------
//连接数据库并将所有首发贴放到$mainrow数组里----------------------------
$connect_id=mysql_connect("localhost","test","test") or die("无法连接数据库");
mysql_select_db("bbs") or die("无法选择数据库");
$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];
相关文章
- 污痕圣杯阿瓦隆的陨落强力召唤物推荐 07-04
- 燕云十六声生财之道万事知窦万金位置一览 07-04
- BLCoin(BLB币)的交易量 07-04
- XRP价格动态:加密货币老手将2美元买入XRP比作50美元购入比特币——XRP能否复制BTC的崛起之路? 07-04
- 云顶之弈摇摆灵动阵容搭配推荐 07-04
- 金铲铲之战s14堡垒莫甘娜阵容搭配指南 07-04