I am using this template to display a rating next to a user.
{insert name=get_percent value=a assign=mpercent userid=$p.USERID}
  {if $mpercent ne ""}
    <div class='user-rate'>
      rate<span class='green'>{$mpercent}%</span>
    </div>
  {else}
    <div class='user-rate'>not rated yet</div>
  {/if}
I'd like to change the rating from a percentage value to a star rating (0-5).
I tried the answer in this link
this is the code as I added the following CSS:
span.stars, span.stars span {
  display: block;
  background:url(../images/stars.png) 0 -16px repeat-x;
  width: 80px;
  height: 16px;
}
span.stars span {
  background-position: 0 0;
}
And JavaScript:
$(function() {
  $("span.stars").stars();
});
$.fn.stars = function() {
  return $(this).each(function() {
    $(this).html($('<span />')
      .width(Math.max(0, (Math.min(5, parseFloat($(this).html())))) * 16));
  });
}
And have used this for each of the ratings:
<p> <span class="stars">{$mpercent}</span>    </p>
i used {$mpercent} to get the rating of the member, but the result is that I get 5 stars all the time.
If I change the value of span class to a fixed number (let us say 1,2 or 3) I also get the same result.