Re: Help!

From: Date: Thu, 15 Mar 2001 05:10:40 +0000
Subject: Re: Help!
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-6042@lists.php.net to get a copy of this message
Perhaps try creating 25 uniq random numbers which correspond to the row numbers, with upper limit tied to the number of rows. ----- Original Message ----- From: "Robin Bolton" <rbolton@lonepinepublishing.com> To: <php-windows@lists.php.net> Sent: Thursday, March 15, 2001 6:52 AM Subject: [PHP-WIN] Help! > Ok, I've managed to get pretty far stuck using MySQL 3.22 and PHP 4.0b2 > for a project I'm working on, however I was hoping someone could help me > with a problem that's probably really simple to fix, just can't get my > head around it right now. > > I need to pull 25 items out of a database randomly with no repeats. Since > I'm using MySQL 3.22 I can't use 'ORDER BY RAND()' and PHP4.0b2 > doesn't > support the 'shuffle()' function (which apparently doesn't work too well > anyways.) > > What I've got so far is: > > for($i = 1; $i < 26; $i++) { > $rArray[$i] = rand(1,count(range(1,25))); > } > > however, that causes repeats. So the bottom line is I need an array with > 25 values (1 to 25) sorted randomly without repeats, and only using PHP > 4.0b2 and earlier functions. > > > Thanks in advance, > > Robin Bolton > Lone Pine Publishing > www.lonepinepublishing.com > rbolton@lonepinepublishing.com > sillyboy@mindless.com >

« previous php.windows (#6042) next »