The output for $per is always 40, even though $result1 and $result are 5 and 4 respectively. I have no idea why this is, please help!
<html>
<body>
<?php
$con = mysql_connect("mysql360int.cp.blacknight.com","u1041802_ahunty","andrew23");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("db1041802_buyer1", $con);
$query1="Select COUNT(rate) AS PositiveRating FROM feedback WHERE rate
= 'positive'";
$result1 =mysql_query($query1);
if(mysql_num_rows($result1))
{
while($row = mysql_fetch_assoc($result1))
{
$PositiveRating = $row['PositiveRating'] ;
echo ("$PositiveRating");
}
}
else
{
echo "<p>No matches were found in the database for your query.</p>\n";
}
$query="Select COUNT(rate) AS NegativeRating FROM feedback WHERE rate
= 'negative'";
$result =mysql_query($query);
echo "<br/>";
if(mysql_num_rows($result))
{
while($row = mysql_fetch_assoc($result))
{
$NegativeRating = $row['NegativeRating'] ;
echo ("$NegativeRating");
}
}
else
{
echo "<p>No matches were found in the database for your query.</p>\n";
}
echo "<br/>";
/*4 + 4*/
$num_total = $result1 + $result;
$per = number_format(($result1 * 100) / $num_total);
echo $per.'%';
if (!mysql_query($query,$con))
{
die('Error: ' . mysql_error());
}
mysql_close($con)
?>
</body>
</html>