Generating a random lottery number in PHP

Hello everyone! I’m new here. I was wondering if anyone has seen or written code that generates a 6 digit random lottery number. I would like to add that feature for the member of my site

Please help. Thanks!

Yes, that is fairly easy to do. PHP can do it with the RAND command…

Here is the link that describes it: http://php.net/manual/en/function.rand.php

It should help… Good luck!

you would simple use 6 variables all using php rand function
[php]
$rand1=rand(1,52);
$rand2=rand(1,52);
$rand3=rand(1,52);
$rand4=rand(1,52);
$rand5=rand(1,52);
$rand6=rand(1,52);

echo $rand1.’, ‘.$rand2.’, ‘.$rand3.’, ‘.$rand4.’, ‘.$rand5.’, '.$rand6;
[/php]
and if you want to get tricky do it with images of balls with numbers on them from one to fifty two or whatever, then name each image according to the number on the ball:
1.jpg
2.jpg

Then do something like:
[php]
<img src=<? echo $rand1; ?>.jpg>
<img src=<? echo $rand2; ?>.jpg>
<img src=<? echo $rand3; ?>.jpg>
<img src=<? echo $rand4; ?>.jpg>
<img src=<? echo $rand5; ?>.jpg>
<img src=<? echo $rand6; ?>.jpg>
[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service