$sql = 'SELECT entryid, avgrating, num_ratings, avgrating*num_ratings AS ordervalue FROM entries ORDER BY ordervalue';