PHP页面渲染数据统计
效果图
PHP代码内置代码
<h3 class="panel-title">站点内容统计:</h3>
</div>
<ul class="list-group">
<li class="list-group-item"><strong><?php echo $posts_count[0]['文章']?></strong>篇文章(<strong><?php echo $posts_drafted_count[0]['草稿']?></strong>篇草稿)</li>
<li class="list-group-item"><strong><?php echo $categories_count[0]['分类']?></strong>个分类</li>
<li class="list-group-item"><strong><?php echo $comments_count[0]['评论']?></strong>条评论(<strong><?php echo $comments_held_count[0]['待审']?></strong>条待审核)</li>
</ul>
在这里插入代码片
数据库查询代码
<?php
//载入配置文件
require_once "../config-2.php";
//记录SESION
// session_start();
// if(empty($_SESSION['current_login_user'])){
// header('Location:/admin/login-2.php');
// }
require_once "../function.php";
//查询语句
//输出文章
$posts_count = baixiu_fetch_all("select count(1) as 文章 from posts");
//输出草稿
$posts_drafted_count = baixiu_fetch_all("select count(1) as 草稿 from posts where status = 'drafted'");
// var_dump($posts_count[0]['num']);
//输入分类
$categories_count = baixiu_fetch_all("select count(1) as 分类 from categories");
//输入评论
$comments_count = baixiu_fetch_all("select count(1) as 评论 from comments");
//输出待审
$comments_held_count = baixiu_fetch_all("select count(1) as 待审 from comments where status = 'held'");
//输出草稿
?>
数据库查询结果代码
查询草稿
查询评论数量
查询发布状态
查询分类数量
查询文章数量
//PHP服务器接口代码
<?php
//载入配置爱文件
require_once 'config-2.php';
//封装公用函数
session_start();
//判断用户是否存在
function BAIXIU_get_current_user () {
if (empty($_SESSION['current_login_user'])){
//不存在跳转主页面
header('Location:/admin/login-1.php');
exit();
}
return $_SESSION