I am using the following code to generate random numbers. With the probability of getting lower numbers higher than getting high numbers.
function fun() {
$num = mt_rand(1, 100);
if ($num > 0 && $num <= 90) {
$return = mt_rand(10, 45) / 10; // 90%
} else if ($num > 90 && $num <= 98) {
$return = mt_rand(45, 100) / 10; // 8%
} else {
$return = mt_rand(100, 200) / 10; // 2%
}
return sprintf("%01.1f",$return);
}
However my coding experience is very basic, I am essentially teaching myself and I am unsure as to how to get the result of this function into a form that I could then add to my database..
I know the below won't make sense but maybe it will make my goal clearer..
$interest = (the result of fun())
mysql_query("UPDATE r$game[0]_$tab[pimp] SET suisseint=$interest WHERE id=$user1no[id];");
Thank you!
Aucun commentaire:
Enregistrer un commentaire