What will the code below be if value is 2 and counter is 11? What would $rating be?
$rating = (@round($rs[value] / $rs[counter],1)) * 10;
The complete code is below.
function getRating(){
$sql= "select * from vote";
$result=@mysql_query($sql);
$rs=@mysql_fetch_array($result);
$rating = (@round($rs[value] / $rs[counter],1)) * 10;
echo $rating;
}
Well, that actually depends on what
$rs[value]and$rs[counter]contain rather thanvalueandcounterthemselves. But my question to you is:That’ll probably give you the right answer, surprisingly enough, rather than having one of us do it for you.
Responding to your comment:
Maybe, but there’s ample precedent on StackOverflow where the question that was asked is frequently replaced, over time, by the question that was meant. That’s not a problem and the best help-desk-type people (including those, like myself, who look after countless family computers) are those who can tease out the real question without insulting the intelligence of the asker 🙂
In any case, the
1argument to the round function specifies how many fractional places are used to round the number, so:and so on.