Depends where is the data.
If you use a DB server, you can simply use the DB server's function (such as RAND()).
A simple MySQL query would be:
SELECT id, question FROM questions ORDER BY RAND() LIMIT 1,0;
You can also generate a random number using rand() and use:
SELECT id, question FROM questions WHERE id = '<random_numer_comes_here>' LIMIT 1,0;
But you'll have to ensure that that the id number exists (you can use a loop until you find one or reach max tries).
Hope that helps.
To pick random results from an array in PHP you will need to use the array_rand() function, you can select the amount of results you wish it too select too. <?php $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); $rand_results = array_rand($array, 3); // will select 3 random results from the array and store in a new array ?>
PHP is a server-side scripting language that can be used to dynamically generate the content of web sites served up to a client. It can also be used for local shell scripting. PHPMyAdmin is a PHP based web interface for managing MySQL databases.
Each item in the population has an equal chance to be chosen. Usually a computer algorithm is used to generate a set of random numbers (most spreadsheet . Then the items are chosen using the set of random numbers, either as they come off the assembly line or if they are serialized, you can just go pick those items.
Use the function "rand()" or "mt_rand()". Both functions will generate a random number (as a return value, so be sure to make it point to a variable - see examples). However, "rand()" is slower and uses a default PHP randomizing system. mt_rand() is four times as fast, and uses the Mersenne Twister randomizing format - which is much more random. Both functions have two optional parameters - a minimum integer and a maximum integer, respectively. By filling in these parameters, you will get a random number between the values you give (so, giving one and five will give you a random number that is no less than one, and no greater than five). These, again, are optional - and if left blank, the tiniest integer possible is no less than 0, and the largest integer possible is generated by the PHP function "getrandmax()" / "mt_getrandmax()" automatically. Examples, of which all are acceptable: ---- /* Examples using no parameters */ $randomNumber = rand(); $randomNumber = mt_rand(); /* Examples using parameters */ $randomNumber = rand(1, 5); $randomNumber = mt_rand(6, 10); ---- If your PHP build is version 4.2 or under, you will need to seed the random number generator with a value to base off of. "srand()" and "mt_srand()" (to be used with rand() and mt_rand() functions, respectively) can be used in this case. They both only have one optional parameter, which is any seed value - any number. If omitted, a random seed will be generated. More acceptable examples: ---- // Example using no parameters srand(); $randomNumber = rand(); // Example using the seed parameter srand(12345); $randomNumber = rand(); // Example using the "mt" random format functions (without parameters) mt_Rand(); $randomNumber = mt_rand(); // Example using the "mt" random format (with parameters) mt_rand(12345); $randomNumber = mt_rand(); ----
well if i didntwould i answer this?think about that love you :)
You can use the Randomize() function in order for you to get random questions from your database. You can use the primary keys in the database for each question as the basis for the randomization process.
There is a RAND function which can generate random numbers. The RANDBETWEEN function can generate numbers between a lower and upper limit.There is a RAND function which can generate random numbers. The RANDBETWEEN function can generate numbers between a lower and upper limit.There is a RAND function which can generate random numbers. The RANDBETWEEN function can generate numbers between a lower and upper limit.There is a RAND function which can generate random numbers. The RANDBETWEEN function can generate numbers between a lower and upper limit.There is a RAND function which can generate random numbers. The RANDBETWEEN function can generate numbers between a lower and upper limit.There is a RAND function which can generate random numbers. The RANDBETWEEN function can generate numbers between a lower and upper limit.There is a RAND function which can generate random numbers. The RANDBETWEEN function can generate numbers between a lower and upper limit.There is a RAND function which can generate random numbers. The RANDBETWEEN function can generate numbers between a lower and upper limit.There is a RAND function which can generate random numbers. The RANDBETWEEN function can generate numbers between a lower and upper limit.There is a RAND function which can generate random numbers. The RANDBETWEEN function can generate numbers between a lower and upper limit.There is a RAND function which can generate random numbers. The RANDBETWEEN function can generate numbers between a lower and upper limit.
Random Questions are awesome! [;
There is actually a website called Random Questions. There is an explanation of the importance of random questions and a list of 50 random questions. These questions are intended to be used for starting conversations.
PHP is a programming language, and parser specifically is part that reads human-readable representation of code to generate parse tree and later opcode representation of code that can be interpreted by php interpreter.
To pick random results from an array in PHP you will need to use the array_rand() function, you can select the amount of results you wish it too select too. <?php $array = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); $rand_results = array_rand($array, 3); // will select 3 random results from the array and store in a new array ?>
Random numbers can be generated in Java using the "random" class. One needs a single "random" object to generate a series of random numbers as a unit.
Very.
family feud
PHP is a server-side scripting language that can be used to dynamically generate the content of web sites served up to a client. It can also be used for local shell scripting. PHPMyAdmin is a PHP based web interface for managing MySQL databases.
PHP is a programming language that is used to generate dynamic web pages based on user requests and other data that changes such as store inventory, current news, or time of day.
The following PHP function is an example of how you could achieve this: You would then call the function as follows: where *MARK* is the mark I hope this has helped, Cpl.Vadera