12-26-2016, 10:33 AM
ohk tried something.
for example here are a bunch of questions with there answers defined at question_list table by the admin/you at the db.
![[Image: 4be6c15166.png]](http://puu.sh/t1oQV/4be6c15166.png)
here is he code:
and here is the live review what the code does:
![[Image: ae1f5b2ab5.gif]](http://puu.sh/t1pdL/ae1f5b2ab5.gif)
And if you want do implement a checking type system then you can try this:
index.php:
here i have used config.php for logging the php file to the system..
and the check.php file can be like this:
and here is its live demo:
![[Image: 8f6c8c59b1.gif]](http://puu.sh/t1skk/8f6c8c59b1.gif)
if you want config.php also then here it is:
for example here are a bunch of questions with there answers defined at question_list table by the admin/you at the db.
![[Image: 4be6c15166.png]](http://puu.sh/t1oQV/4be6c15166.png)
here is he code:
PHP Code: (Select All)
$sql = "SELECT * FROM question_list order by RAND() LIMIT 1";
$result = $connect_db->query($sql);
$row = $result->fetch_assoc();
$question = $row['question'];
$answer = $row['answer'];
echo "<b>Question: </b>".$question."<br><b>Answer: </b>".$answer;
and here is the live review what the code does:
![[Image: ae1f5b2ab5.gif]](http://puu.sh/t1pdL/ae1f5b2ab5.gif)
And if you want do implement a checking type system then you can try this:
index.php:
PHP Code: (Select All)
include 'config.php';
$sql = "SELECT * FROM question_list order by RAND() LIMIT 1";
$result = $connect_db->query($sql);
$row = $result->fetch_assoc();
$question = $row['question'];
$answer = $row['answer'];
if($row != null) {
echo "<b>Question: </b>".$question."<br>";
echo "<form method='POST' action='check.php'>
<input type='hidden' name='question' value='".$question."'/>
<input type='text' placeholder='Type Answer' name='answer'/>
<button type='submit'>SUBMIT</button>
</form>";
//echo "<b>Question: </b>".$question."<br><b>Answer: </b>".$answer;
}
and the check.php file can be like this:
PHP Code: (Select All)
include 'config.php';
$question = $_POST['question'];
$sql = "SELECT * FROM question_list WHERE question='$question'";
$result = $connect_db->query($sql);
$row = $result->fetch_assoc();
$question = $row['question'];
$answer = $row['answer'];
if($_POST['answer'] == $answer) {
echo 'Correct!';
} else {
echo 'Wrong!';
}
![[Image: 8f6c8c59b1.gif]](http://puu.sh/t1skk/8f6c8c59b1.gif)
if you want config.php also then here it is:
PHP Code: (Select All)
$connect_db = mysqli_connect("hostname here", "username of account of mysql", "accountt password", "databasename");
if(!$connect_db) {
die("<b>Warning!</b> Connection Failed: ".mysqli_connect_error());
}
Administrator
admin@post4vps.com