ecshop 评价仿京东仿淘宝 中评率 好评率 差评率

效果图 

 

1.在goods.php中添加 

//中差评
$sql="select * from ".$ecs->table('comment')." where comment_type=0 and status=1 and comment_rank!=0 and id_value=$goods_id";
$comments=$db->getall($sql);

$count=count($comments);

$zhonghao='';
$zhonghaoimg='';

$hao=0;
$zhong=0;
$cha=0;

$haol='';
$zhongl='';
$chal='';

foreach($comments as $value){

if($value['comment_rank'] == 1){
$cha=$cha+1;
}

if($value['comment_rank'] == 2 or $value['comment_rank'] == 3 or $value['comment_rank'] == 4){
$zhong=$zhong+1;
}

if($value['comment_rank'] == 5){
$hao=$hao+1;
}

}

$smarty->assign('zhonghao', round($hao/$count*100,0));
$smarty->assign('count', $count);
$smarty->assign('zhong', round($zhong/$count*100,0));
$smarty->assign('cha', round($cha/$count*100,0));

$smarty->assign('haol', round($hao/$count*100/100*143,0));
$smarty->assign('zhongl', round($zhong/$count*100/100*143,0));
$smarty->assign('chal', round($cha/$count*100/100*143,0));

$smarty->assign('zhonghaoimg', round($hao*5/$count,0));

 

接下来就是在模板中调用 这些就可以了  $smarty->assign('haol', round($hao/$count*100/100*143,0));   这里面的 143 是那个评价进度条的总长度

 

ecshop二次开发 联系QQ 1595192997

 

posted @ 2013-08-17 04:13  随心^_^  阅读(1585)  评论(0编辑  收藏  举报