Well there are many ways to do this.
1) Use a wieghted SQL query (that don't help here)
2) Fill an array with the possibilities and choose at random from the array, for example.
Lets assume:
Red ball = 1 (weight 15)
Black ball = 2 (weight 3)
Blue Ball = 3 (Wieght 2)
So our array of numbers is :
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,3,3]
Choose a random position from the array and select the correct ball :)
This method is used widely.
1) Use a wieghted SQL query (that don't help here)
2) Fill an array with the possibilities and choose at random from the array, for example.
Lets assume:
Red ball = 1 (weight 15)
Black ball = 2 (weight 3)
Blue Ball = 3 (Wieght 2)
So our array of numbers is :
[1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,3,3]
Choose a random position from the array and select the correct ball :)
This method is used widely.