我的产品相当于介质和全如何计算产品估值系统的正确百分比?
例的明星价值的系统:
0.5
- 1
- 1.5
- 2
- 2.5
- 3
- 3.5
- 4
- 4.5
- 5
我得到的数据正确地采取两个数据一个中等和整体和总和两个值
从以下咨询:
//we define in a variable the id of the product valued by the valuation system
$id_product = 1;
//we obtain an average and integer value equivalent to 4.5 and 5
$stmt = $con->prepare("SELECT SUM(rating) as total FROM ratings WHERE id_product=? AND rating in(4.5,5)");
$stmt->bind_param("i",$id_product);
$stmt->execute();
$stmt->bind_result($sum);
while ($stmt->fetch()) {
echo $sum;
}
//we obtain an average and integer value equivalent to 3.5 and 4
$stmt = $con->prepare("SELECT SUM(rating) as total FROM ratings WHERE id_product=? AND rating in(3.5,4)");
$stmt->bind_param("i",$id_product);
$stmt->execute();
$stmt->bind_result($sum);
while ($stmt->fetch()) {
echo $sum;
}
//we obtain an average and integer value equivalent to 2.5 and 3
$stmt = $con->prepare("SELECT SUM(rating) as total FROM ratings WHERE id_product=? AND rating in(2.5,3)");
$stmt->bind_param("i",$id_product);
$stmt->execute();
$stmt->bind_result($sum);
while ($stmt->fetch()) {
echo $sum;
}
//we obtain an average and integer value equivalent to 1.5 and 2
$stmt = $con->prepare("SELECT SUM(rating) as total FROM ratings WHERE id_product=? AND rating in(1.5,2)");
$stmt->bind_param("i",$id_product);
$stmt->execute();
$stmt->bind_result($sum);
while ($stmt->fetch()) {
echo $sum;
}
//we obtain an average and integer value equivalent to 0.5 and 1
$stmt = $con->prepare("SELECT SUM(rating) as total FROM ratings WHERE id_product=? AND rating in(0.5,1)");
$stmt->bind_param("i",$id_product);
$stmt->execute();
$stmt->bind_result($sum);
while ($stmt->fetch()) {
echo $sum;
}
现在我的问题是如何能够正确计算数据百分比和得到的结果像下面的图片:
'Sumo'?就像'摔角'一样? – Strawberry
@Strawberry不是那么严重只有一个正确的错误可以说他的意思是“总和” –