** Random Number Generator **
-
Hi Everyone, I have a question regarding generating random number. Is there a function that can generate random number between a range without having the random number repeat itself? For example, let's say I have 100 records in a database. i want to randomly select a certain number of records upon user input and make it as a new table. if i use rand() function, and mod the numbers by 100, i'll get the numbers between 1 and 100, which then i can use to set the position of the record to copy that row of data. but the numbers might repeat themself if i select a large amount of records out of the 100. is there a way to check the random number generated to see if it has already been selected before? If anyone knows, plmk. thanks steve
-
Hi Everyone, I have a question regarding generating random number. Is there a function that can generate random number between a range without having the random number repeat itself? For example, let's say I have 100 records in a database. i want to randomly select a certain number of records upon user input and make it as a new table. if i use rand() function, and mod the numbers by 100, i'll get the numbers between 1 and 100, which then i can use to set the position of the record to copy that row of data. but the numbers might repeat themself if i select a large amount of records out of the 100. is there a way to check the random number generated to see if it has already been selected before? If anyone knows, plmk. thanks steve
== false) { // do your code gen[x] = true; } else { // try again } -
Hi Everyone, I have a question regarding generating random number. Is there a function that can generate random number between a range without having the random number repeat itself? For example, let's say I have 100 records in a database. i want to randomly select a certain number of records upon user input and make it as a new table. if i use rand() function, and mod the numbers by 100, i'll get the numbers between 1 and 100, which then i can use to set the position of the record to copy that row of data. but the numbers might repeat themself if i select a large amount of records out of the 100. is there a way to check the random number generated to see if it has already been selected before? If anyone knows, plmk. thanks steve