Hello.
I am working on a download system and ran into a little problem with the rating system.
each row has a column "rating" which are numbers 1 though 5.
This is what I tried:
$result = mysql_query("SELECT AVG(rating) FROM download_filerate WHERE fileid = '".$row2['id']."'");
while (list($average) = mysql_fetch_array($result)) {
if($average < "1") {
$rating = "<img border=\"0\" src=\"/images/rank0.gif\" alt=\"$average of 5 average\">";
} elseif ($average == "1") {
$rating = "<img border=\"0\" src=\"/images/rank1.gif\" alt=\"$average of 5 average\">";
} elseif ($average == "2") {
$rating = "<img border=\"0\" src=\"/images/rank2.gif\" alt=\"$average of 5 average\">";
} elseif ($average == "3") {
$rating = "<img border=\"0\" src=\"/images/rank3.gif\" alt=\"$average of 5 average\">";
} elseif ($average == "4") {
$rating = "<img border=\"0\" src=\"/images/rank4.gif\" alt=\"$average of 5 average\">";
} elseif ($average == "5") {
$rating = "<img border=\"0\" src=\"/images/rank5.gif\" alt=\"$average of 5 average\">";
}
}
The problem: If there is only 1 vote made it shows average is 2.0000 of 5. Is this right?
Also... $average is showing a decimal followed by three zero's.. how do i make it just one digit?
cheers.