您的位置:首页 > 数据库 > MySQL

小型bbs论坛系统开发8 首页

2017-01-13 23:27 316 查看
<?php
include_once './inc/tool.inc.php';
include_once './inc/config.inc.php';
include_once './inc/mysql.inc.php';

// mysqli中获取时间的知识点补充:
// NOW()    CURDATE()   CURTIME()
// 2008-12-29 16:25:46  2008-12-29  16:25:46

//初始化css
$cssArray = array('public.css','index.css');
//初始化网站标题
$webTitle = '首页';
//获取数据库连接
$link = sql_connect();
//验证登录状态
if(!$member_id=is_login($link)){
skip('login.php?url=index.php','error','请先登录!');
}

?>

<?php include_once './inc/header.inc.php'; ?>
<!-- 热门动态开始 -->
<div id="hot" class="auto">
<div class="title">热门动态</div>
<ul class="newlist">
<!-- 20条 -->
<li><a href="#">[库队]</a> <a href="#">私房库实战项目录制中...</a></li>

</ul>
<div style="clear:both;"></div>
</div>
<!-- 热门动态结束 -->

<!-- 父板块开始 -->
<?php
$query = "select * from sfk_father_module order by sort asc";
$result_father = sql_execute($link,$query);
while($data_father = mysqli_fetch_assoc($result_father)){
?>
<div class="box auto">
<div class="title">
<!-- 输出父板块名称 -->
<?php echo "<a href = 'list_father.php?id={$data_father['id']}'>{$data_father['module_name']}</a> "; ?>
</div>
<div class="classList">
<!-- 输出子板块名称 开始-->
<?php
$query = "select * from sfk_son_module where father_module_id = {$data_father['id']} order by sort asc";
$result_son = sql_execute($link,$query);
if(mysqli_num_rows($result_son)){
while($data_son =mysqli_fetch_assoc($result_son)){
// 获取今日帖子数量
$query = "select count(*) from sfk_content
where module_id = {$data_son['id']}
and time > curdate()";
$countToday = sql_num($link,$query);

// 获取历史帖子发布数量
$query = "select count(*) from sfk_content
where module_id = {$data_son['id']}";
$countAll = sql_num($link,$query);

$html = <<<B
<div class="childBox new">
<h2>
<a href="#">{$data_son['module_name']}</a>
<span>(今日{$countToday})</span>
</h2>
帖子:{$countAll}<br />
</div>
B;
echo $html;
}
}else{
echo '<div style="padding:10px 0;">暂无子版块...</div>';
}
?>
<!-- 输出子板块名称 结束 -->
<div style="clear:both;"></div>
</div>
</div>
<?php }?>
<?php include_once './inc/footer.inc.php'; ?>


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  bbs 论坛 mysqli