I got a cell in my table called platform_rating which shall be the percentual
value of of the division of two other cells (platform_likes / total_votes)*100. Whenever somebody clicks the like button, ‘platform_likes’, ‘total_votes’ are updated but ‘platform_rating’ is not. Here is the row in the array:
<?php
'platform_rating' => ($row['total_votes'] != 0) ? ($row['platform_likes'] /
$row['total_votes'])*100 : 0,
?>
and here is the function to update:
<?php
function add_like($platform_id)
{
$platform_id = (int)$platform_id;
mysql_query("UPDATE `flights` SET `platform_likes` = `platform_likes` + 1,
`total_votes` = `total_votes` + 1, **`platform_rating` =
`platform_rating`((platform_likes / total_votes)*100)** WHERE platform_id =
$platform_id");
}
?>
You’re multiplying the percentage by
platform_ratingbecause of a strayplatform_ratingin your UPDATE query. It should read platform_rating = ((platform_likes / total_votes)*100)