直接上代码吧 下面代码扔到module.php
代码语言:javascript复制<?php
//评论
function comments_count(){
global $userData;
$DB = Database::getInstance();
$result=$DB->query('SELECT count(*) as "counts" FROM '.DB_PREFIX.'comment where mail="'.$userData['email'].'"');
$res = $DB->fetch_array($result);
return $res['counts'];
}
//未审核文章数
function count_no(){
global $userData;
$DB = Database::getInstance();
$result=$DB->query('SELECT COUNT(*) AS "total" FROM ' . DB_PREFIX . 'blog WHERE author="'.$userData['uid'].'" AND checked = "n" AND type = "blog"');
$res = $DB->fetch_array($result);
return $res['total'];
}
//已审核文章数
function count_yes(){
global $userData;
$DB = Database::getInstance();
$result=$DB->query('SELECT COUNT(*) AS "total" FROM ' . DB_PREFIX . 'blog WHERE author="'.$userData['uid'].'" AND checked = "y" AND type = "blog"');
$res = $DB->fetch_array($result);
return $res['total'];
}
?>
食用方法
下面的放到你想要显示的地方即可
<?php echo comments_count(); ?> <?php echo count_no(); ?> <?php echo count_yes(); ?>