If I understand what you want, its simply to add like a x/y ratio for the votes out of the total votes?
The first thing that has to change no matter what you do is that $no + $yes has to go. If no votes exist, it will try to divide by 0 which of course is undefined. You know how many exist otherwise.