Hi! Could we please enable some services and cookies to improve your experience and our website?
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
<?php
$conn = &$mysqli;
$sql = mysqli_query($conn, "SELECT * FROM `questions_tab` ORDER BY RAND() LIMIT 1");
$q = mysqli_fetch_array($sql);
echo '<b>Question '.$q['id'].' ::<br /><br />'.$q['question'].'</b><br /><br />';
$qry = mysqli_query($conn, "SELECT * FROM `options_tab` WHERE question_id = " . $q['id']);
while ($o = mysqli_fetch_array($qry)) {
echo'<input type="radio" name="ans" value="'.$o['id'].'"> '.$o['opt'].'<br /><br />';
}
echo'<br><button type="submit"> Submit</button></form>';