How to fetch random data from Table in php MySqli

In this example we fetch radom question for online test.For this we need to file

We using rand() function for fetch radom question.


 die('Could not Connect My Sql:' .mysql_error());


include_once 'database.php';

$result = mysqli_query($conn,"SELECT * FROM questions order by RAND() limit 5");

<!DOCTYPE html>
<title> Retrive data</title>
<td>Sl No.</td>
while($row = mysqli_fetch_array($result)) {
<tr >
<td><?php echo $row["id"]; ?></td>
<td><?php echo $row["questions"]; ?></td>
?> </table> </body> </html>

Related Topic

Fetch data show in select box

Fetch data show in checkbox

Fetch data show in radio button

Fetch data show in text box