Jiraiya Posted April 7, 2009 Share Posted April 7, 2009 i was wondering how would i make it so a random word from a list would be put into a database table when they sign up for my site? so in other words i want to have a random word to be set as one of the users variables when they sign up and i want to have it so that each word has a preset percentage of that word being picked for the database. Quote Link to comment Share on other sites More sharing options...
revraz Posted April 7, 2009 Share Posted April 7, 2009 Have a table that stores the random words, then use a random number generator for as many rows as you have and let it pick one. Quote Link to comment Share on other sites More sharing options...
Jiraiya Posted April 7, 2009 Author Share Posted April 7, 2009 so i have to make a different database that contains the words? then how would i make a percent chance that a word will be choosen to be placed into the users variable when they sign up since i dont want the user to pick it? Quote Link to comment Share on other sites More sharing options...
revraz Posted April 7, 2009 Share Posted April 7, 2009 http://php.net/rand You don't have to use a DB, you can use a static array as well, up to you. You want it flexible or do you want to hard code it? Quote Link to comment Share on other sites More sharing options...
Yesideez Posted April 7, 2009 Share Posted April 7, 2009 Wouldn't it be easier just to use random numbers instead? If you want a random number between 1000 and 9999 you'd use: $num=mt_rand(1000,9999); Quote Link to comment Share on other sites More sharing options...
Jiraiya Posted April 7, 2009 Author Share Posted April 7, 2009 no i dont want random numbers i want random words from a list i create and then have a set percentage that that word will be chosen Quote Link to comment Share on other sites More sharing options...
Jiraiya Posted April 7, 2009 Author Share Posted April 7, 2009 how would i make it so a random number is picked and then stored all in the same script? Quote Link to comment 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.