ableroos Posted November 8, 2009 Share Posted November 8, 2009 I am combining 2 words out of a table with about 60,000 rows to create random names. I have used RAND() but it is way too slow. Here is my code: $sqlquery = "SELECT text FROM words ORDER BY RAND() LIMIT 2"; $results = mysql_query($sqlquery); while ($row = mysql_fetch_array($results, MYSQL_NUM)) { echo strtoupper ($row[0] . " " . $row[1]); } Can anyone suggest a faster alternative and show me an example? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/180769-need-faster-alternative-to-rand/ Share on other sites More sharing options...
Alex Posted November 8, 2009 Share Posted November 8, 2009 See http://www.phpfreaks.com/forums/index.php/topic,125759.0.html Quote Link to comment https://forums.phpfreaks.com/topic/180769-need-faster-alternative-to-rand/#findComment-953698 Share on other sites More sharing options...
ableroos Posted November 8, 2009 Author Share Posted November 8, 2009 The problem with the solutions on that page is all the selections end up pulling from the same region of the database so word 1 is always a word beginning with "A" and the second word is almost always word that begins with A as well or perhaps a "B". They are random, but not very random if that makes sense. Quote Link to comment https://forums.phpfreaks.com/topic/180769-need-faster-alternative-to-rand/#findComment-953784 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.