php - Randomly generate numbers based on stock in MySQL database -
Hi guys, I need some help with a script in PHP, currently it is setup as a slot style game. Where users can pay a little bit and generate 3 random numbers, each number can be associated with a prize which they can win. Match 3 and win said the award
Unfortunately as always I will not be in stock to give each item as a reward, I have to check through each number and make sure that it is in stock
And if it is in stock, then add it to an algorithm which will randomly select 3 numbers Currently I have such setup > which generates numbers based on two variables and connects each number with an award, obviously it does not notice which numbers in the stock are I, And it does not allow for the edge. I have a simple way to find out that any object is in stock and if it has been stocked, then it can be won, in the list of awards Added, I need it To keep an edge, some awards will appear very often (too much), such as the simple values like Code X, the likelihood of being compared to others is 0.25% and Cody Y has the chance to have 50%. If I set it with a large range of numbers ... ... I am still leaving or leaving the prizes that I do not have - or if I keep a code, check it out Can add an embedded one if he is giving it and if it does not give either reward Or does not offer any default prize. But this would mean that most of the codes have been given in my stock, which has been given to me, which I do not want to do, I really want to do it with predefined obstacles I want to be completely neutral with this .. So hopefully everyone who understands this is not a very complex problem, but I think that is quite unusual To read New Testament Scanning your questions, I think you need to change your query < Pre> With this you choose the first 3 and you get 3 random prizes, this is a quick solution. I think I find it after some more testing ... Edit > You get a column Additional code: then the last code is $ stock = $ cone - & gt; Query (Select 'Select from item id where available = 1');
function generated_number () {global $ number; $ Number = array ('0' => Rand (1,2), '1' => Rand (1,2), '2' => Rand (1,2)); Display_numbers (); }
function_production_number () {global $ number; $ Number = array ('0' => Rand (1,100), '1' => Rand (1,100), '2' => Rand (1,100)); Display_numbers (); }
if (($ numbers [0]> gt; & amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; ($ numbers [0] & lt; 40)) Award x "; And if (($ numbers [0]> 40) & amp; amp; ($ number [0] <50)) Echo" You won the prize "; Else {Resonance" You award z Win ";}
$ stock = $ conn - & gt; Query ('Select item item where code is available = 1 by rand (order)');
chance , which is a number, and the probability of seeing the probability of that record is when there is an additional code on N:
0 = Floor (rand (* * chance)
$ stock = $ conn - & gt; The query ('Select from the different item ID where the code is available = 1 and 0 = floor (rand (* * chance) by rand ()' order););
Comments
Post a Comment