0

This is the Code:

<?php
    $db=mysqli_connect('localhost', 'root', '', 'db');
    $sql = 'SELECT `Questions`, `OptionA`, `OptionB`, `OptionC`, `OptionD` FROM `ccoai questions` ORDER BY RAND() LIMIT 2';
    $result = $db->query($sql);
    echo '<table width="100%">
    ';

    // Print each file
    for($i=0;$i<$limit;$i++)
    {
    echo "<ol><li>";
    while($row = $result->fetch_assoc()) {
       // $nice_date = date('d-m-Y', strtotime( $row['doregistration'] ));
        echo "
            <tr>
                <td>{$row['Questions']}</td></tr>
                <tr><td><input type='radio' value='{$row['OptionA']}'>{$row['OptionA']}</td></tr>
                <tr><td><input type='radio' value='{$row['OptionB']}'>{$row['OptionB']}</td></tr>
                <tr><td><input type='radio' value='{$row['OptionC']}'>{$row['OptionC']}</td></tr>
                <tr><td><input type='radio' value='{$row['OptionD']}'>{$row['OptionD']}</td></tr>
            </tr>";
    }

    // Close table
    echo '</li></ol></table>';
    }
}

// Free the result
$result->free();
}
 else
{
echo 'Error! SQL query failed:';
echo "<pre>{$db->error}</pre>";
}

// Close the mysql connection
$db->close();

    ?>
Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141
    1. {$row['Questions']}
    I tried this and this also doesnt work
    – e-logiX Youtube Oct 09 '18 at 13:06
  • needs to be outside the loop,
  • inside
  • – Matt Jameson Oct 09 '18 at 13:07
  • you are best of giving us an ideal of what you want the finished article to look like. Edit your question with a display of what you need it to look like – Matt Jameson Oct 09 '18 at 13:56