Re: [PHP-DB] Random - not that random

2001-05-17 Thread Ken Wills

Hi Dan,

You need to call mt_srand() first to seed the random number generator. It's all 
described here:

http://www.php.net/manual/en/function.mt-rand.php

Ken

* Dan Eskildsen <[EMAIL PROTECTED]> [010517 14:22]:
> Newbie alert
> 
> Hi!  Here is a piece of coding.  It randomly choose between four options to
> display on my homepage.  The problem is that it doesn't seem to be that
> random - rather biased.  The last option $message[3] is displayed 9 out of
> 10 times.  Any suggestions?
> 
> 
> 
> $message[0] = ' src="images/trolley.jpg">
Rengøringsvogne, mopper m.m.
'; > $message[1] = ' src="images/nilfisk.gif">
Nilfisk Advance rengøringsmaskiner
'; > $message[2] = ' src="images/ladder.jpg">
Har du set vores Vinduespudserstiger?
'; > $message[3] = ' border="0"src="images/logo-bison.gif">
Vi importerer selv vore polisher > fra en af Canadas førende Polishfabrikker.
'; > > $number = mt_rand(0,3) ; > print"$message[$number]"; > > > > -- > == > Regards from Denmark, Europe > Please cc your reply to [EMAIL PROTECTED] > == > I haven't lost my mind, I've got it backed up on TAPE somewhere... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]

[PHP-DB] Random - not that random

2001-05-17 Thread Dan Eskildsen

Newbie alert

Hi!  Here is a piece of coding.  It randomly choose between four options to
display on my homepage.  The problem is that it doesn't seem to be that
random - rather biased.  The last option $message[3] is displayed 9 out of
10 times.  Any suggestions?



$message[0] = '
Rengøringsvogne, mopper m.m.
'; $message[1] = '
Nilfisk Advance rengøringsmaskiner
'; $message[2] = '
Har du set vores Vinduespudserstiger?
'; $message[3] = '
Vi importerer selv vore polisher fra en af Canadas førende Polishfabrikker.
'; $number = mt_rand(0,3) ; print"$message[$number]"; -- == Regards from Denmark, Europe Please cc your reply to [EMAIL PROTECTED] == I haven't lost my mind, I've got it backed up on TAPE somewhere... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]