Log in

View Full Version : Random Number



Rockonmetal
09-15-2007, 05:47 PM
I want to have a random number between 1 and 100 display on my page... how do I get this without using javascript!
Thanks to all who help!

Twey
09-15-2007, 06:06 PM
<?php echo rand(0, 100); ?>

Rockonmetal
09-15-2007, 06:08 PM
K thnx! so if i wanted to turn this into a variable i would do this:

<?php
$rand = rand(0, 100);
?>

Would that be right?
Thanks for the quick response

Yeah that works I just tried it THANKS SO MUCH!!!!!!!!!!!!

thetestingsite
09-15-2007, 09:14 PM
You could also use mt_rand() (http://us2.php.net/mt_rand) for better random numbers between what you specify.

Hope this helps.

alexjewell
09-16-2007, 09:18 PM
Isn't a random number between 0 and 100 a random number between 0 and 100? How is one random number better than another?

Rockonmetal
09-16-2007, 09:30 PM
Oh i'm using it for the random math problem of the day... also i will use it to ask a math question to check if it is a computer filling out the form or a human... *or just to do something random...*