RE: [PHP] Picking random numbers

From: Date: Tue, 21 Aug 2001 12:29:50 +0000
Subject: RE: [PHP] Picking random numbers
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-63683@lists.php.net to get a copy of this message
You've gotten a few responses already... but since you didn't describe the application, here is an alternative if you are using the random numbers to retrieve random records from a database (postgreqsl in this example); $query = "SELECT * FROM table ORDER BY random() LIMIT 5"; am usre the MySQL and others have similar constructs... again, just in case you were looking for database use and not just the number use (which others have more than adequately answered for you). Dave >-----Original Message----- >From: Seb Frost [mailto:seb@raceshoot.com] >Sent: Monday, August 20, 2001 9:13 PM >To: PHP General List >Subject: [PHP] Picking random numbers > > >OK I want to pick 5 random numbers from 1 to 200. Easy. They must all be >different. Not so easy. > >And I don't want to use shuffle because of the comments on php.net about it. > >- seb > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net >For additional commands, e-mail: php-general-help@lists.php.net >To contact the list administrators, e-mail: php-list-admin@lists.php.net > > >

« previous php.general (#63683) next »