分类分类
更新时间:2026-03-28 23:52:13作者:zhao

说一下原理:
后台:计算各个类型的评论总和和全部评论。
后台函数代码:
/*统计评论*/
function getcccount($goods_id){
$sql="SELECT count(id_value) FROM ". $GLOBALS['ecs']->table('comment') ." WHERE id_value = $goods_id AND comment_rank!=0 and select_type=0 and parent_id=0";
$count = $GLOBALS['db']->getOne($sql);
if(empty($count)){
return '没有评论';
}
else
{
$sql="SELECT count(id_value) FROM ". $GLOBALS['ecs']->table('comment') ." WHERE id_value = $goods_id AND comment_rank =5 and select_type=0 and parent_id=0";
$count5 = $GLOBALS['db']->getOne($sql);
$sql="SELECT count(id_value) FROM ". $GLOBALS['ecs']->table('comment') ." WHERE id_value = $goods_id AND comment_rank =1 and select_type=0 and parent_id=0";
$count1 = $GLOBALS['db']->getOne($sql);
$sql="SELECT count(id_value) FROM ". $GLOBALS['ecs']->table('comment') ." WHERE id_value = $goods_id and select_type=0 and parent_id=0 AND comment_rank BETWEEN 2 AND 4";
$count3 = $GLOBALS['db']->getOne($sql);
$hb =percent($count5,$count);
$zb =percent( $count3,$count);
$cb =percent($count1,$count);
$arr=array();
$arr['all']=$count; //统计全部评论
$arr['hao']=$count5; //统计好评个数
$arr['zhong']=$count3; //统计中评个数
$arr['cha']=$count1 ; //统计差评个数
$arr['hb']=$hb; //好评百分比
$arr['zb']=$zb; //中评百分比
$arr['cb']=$cb; //差评百分比
return $arr;
}
}
/*百分比计算函数
*$p 被除数
*$t 总个数
*/
function percent($p,$t){
return sprintf('%.2f%%',$p/$t*100);
相关
王道三国策略游戏380.18 MBv0.0.12026-03-28
下载刮个爽手机版休闲益智186.96 MBv1.0.282026-03-28
下载龙符天祭策略游戏756.03 Mv22026-03-28
下载入魂一番赏app网上购物106.66 Mv4.3.52026-03-28
下载童话师经营养成504.02 Mv1.1.52026-03-28
下载Bebo Cam app图像拍照264.51 Mv2.3.02026-03-28
下载纯三国官方正版策略游戏167.24 Mv0.0.12026-03-28
下载Poka Cam app图像拍照74.7 Mv1.8.02026-03-28
下载COLMO app趣味娱乐199.15 Mv2.3.5.22026-03-28
下载愤怒的小鸟变形金刚苹果版休闲游戏439.4 Mv2.39.02026-03-28
下载这也能切苹果版休闲游戏479.6 Mv21342026-03-28
下载口袋吉伊卡哇苹果手机版模拟游戏920.4 Mv2.0.02026-03-28
下载










