In this example we fetch radom question for online test.For this we need to file
We using rand() function for fetch radom question.
<?php
$host='localhost';
$username='root';
$password='';
$conn=mysqli_connect($host,$username,$password,"crud");
if(!$conn){
die('Could not Connect My Sql:' .mysql_error());
}
?>
<?php
include_once 'database.php';
$result = mysqli_query($conn,"SELECT * FROM questions order by RAND() limit 5");
?>
<!DOCTYPE html>
<html>
<head>
<title> Retrive data</title>
</head>
<body>
<table>
<tr>
<td>Sl No.</td>
<td>Questions</td>
</tr>
<?php
$i=0;
while($row = mysqli_fetch_array($result)) {
?>
<tr >
<td><?php echo $row["id"]; ?></td>
<td><?php echo $row["questions"]; ?></td>
</tr>
<?php
$i++;
}
?>
</table>
</body>
</html>
Fetch data show in radio button