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. Link to comment https://forums.phpfreaks.com/topic/152992-solved-php-registration-script-question/ 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. Link to comment https://forums.phpfreaks.com/topic/152992-solved-php-registration-script-question/#findComment-803484 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? Link to comment https://forums.phpfreaks.com/topic/152992-solved-php-registration-script-question/#findComment-803487 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? Link to comment https://forums.phpfreaks.com/topic/152992-solved-php-registration-script-question/#findComment-803488 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); Link to comment https://forums.phpfreaks.com/topic/152992-solved-php-registration-script-question/#findComment-803492 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 Link to comment https://forums.phpfreaks.com/topic/152992-solved-php-registration-script-question/#findComment-803496 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? Link to comment https://forums.phpfreaks.com/topic/152992-solved-php-registration-script-question/#findComment-803532 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.