分类分类
更新时间:2026-08-08 14:32:32作者: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);
相关
代号97动作射击277.47 Mv1.0.72026-08-08
下载日本事故物件监视协会3冒险游戏170.33 MBv1.0.42026-08-08
下载你牛你来休闲益智116.37 MBv1.0.22026-08-08
下载文字密室逃脱手机版冒险游戏255.16 MBv1.62026-08-07
下载苏丹的游戏手机版角色扮演1.02 GBv1.0.62026-08-07
下载超市大亨3D手游经营养成253.14 MBv10.252026-08-07
下载你只能推搡动作射击44.62 MBv1.102026-08-07
下载仙逆本尊手游角色扮演298.41 Mv0.0.42026-08-07
下载天使帝国4手机版角色扮演837.88 Mv1.02026-08-07
下载丹墨三国弈手机版策略游戏2.14 GBv1.0.02026-08-07
下载CM语音App社交通讯95.16 Mv8.16.02026-08-07
下载光氪灵动app实用工具7.6 Mv1.2.12026-08-07
下载










