So ive made a query to calculate a rank for my pages, which is working great. Now however i would like to take in another rank calculation factor. Currently it only take in average and number of votes ( from which i calculate a number to later output the rank ) $value_max = 5; $result = mysql_query("SELECT content_id, ROUND(ROUND(AVG(value) * '{$value_max}' / 100, 4) * (COUNT(content_id) / 100), 4) + '{$num_loved}' AS average FROM votingapi_vote GROUP BY content_id ORDER BY average DESC") or die(mysql_error()); $rank = 1; while($row = mysql_fetch_array($result)) { if($row['content_id'] == $nid) { $movie_rank = $rank; } $rank++; } PHP: The $num_loved is the new factor i wanna take in ( people who loved this page, simple as 1,2,3 or 4 etc ) Taken by mysql_num_rows from a previous query Now when i change $movie_rank = $rank; Code (markup): to $movie_rank = $row['average']; Code (markup): the actual number increases for example from 6.55 to 11.55 which is exactly what i need. Now the actual problem: when i switch back to $rank the movie still got its old rank, while it actually should grow 1 rank higher. Anyone got an idea why? I am totally struck Thanks for any tips, help