Mini Shell
<?php
require_once("../config.php");
require_once("function-file.php");
require_once("function-menu.php");
cookiecheck();
$topic_id=$_GET['topic_id'];
$datas=$conn->prepare("select * from topics where topic_id='$topic_id'");
$datas->execute();$result=$datas->fetch();
if(isset($_POST['save']))
{
$text=$_POST['question'];
$conn->exec("insert into question (topic_id,stu_id,datetime,text) values ('$topic_id','$_COOKIE[userid]',NOW(),'$text')");
header("location:read-topic.php?topic_id=$topic_id#questions");
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title><?php echo $result['topic_name'];?></title>
<!-- Tell the browser to be responsive to screen width -->
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
<?php cssfile();?>
<style type="text/css">
#load {
width:30px;
padding-top:50px;
border:0px green dashed;
margin:0 auto;
}
#paginate {
border:0px green solid;
width:100%;
margin:0 auto;
}
#paginate li{
list-style: none;
float: left;
margin-right: 16px;
padding:5px;
width:80%;
}
.page{ background: #fff;
color: #fff;
font-weight: bold;width:5% !important;
text-align:right;
}
.page.right{
text-align:left;
}
.page .fa{
font-size:30px;
color:#00c0ef;
}
.page:hover {
color:#ddd;
cursor: pointer;
}.hidden { display: none; }
.active{display:inline !important;}
.left{float:left}.ex-radio{width:20px;height:20px;cursor:pointer;}.rad{margin-top: -5px;}
.answer{ color: #00a65a; font-weight: bold;display:none}.hint{display:none;}
#paginate > li:not(.page) .btn-info{ min-width: 109px; }
</style>
</head>
<body class="hold-transition skin-blue layout-top-nav">
<!-- Site wrapper -->
<div class="wrapper">
<?php headermenu();?>
<!-- =============================================== -->
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<!-- Main content -->
<section class="content">
<!-- Default box -->
<div class="box">
<div class="box-header with-border">
<h3 class="box-title"><?php echo $result['topic_name'];?></h3>
<div class="box-tools pull-right">
<a href="javascript:history.back()" class="btn btn-info btn-sm" ><i class="fa fa-angle-double-left"></i> Back</a>
</div>
</div>
<div class="box-body">
<div class="form-group">
<div >
<ul id="paginate">
<li id="" class="page" data-value="prev"><i class="fa fa-toggle-left" data-toggle="tooltip" title="Previous" data-placement="bottom"></i></li>
<?php $data=$conn->prepare("select * from practice where topic_id='$topic_id'");
$data->execute();$result=$data->fetchall();$nums=$data->rowcount();$i=1;
foreach($result as $row){?>
<li id="<?php echo $i;?>" class="hidden sec <?php if($i==1){echo"active";}?>">
<table class="table table-bordered table-striped">
<thead><tr><td><span class="left"><b>Question <?php echo $i;?>: </b></span><span class="left"> <?php echo $row['question'];?></span></td></tr></thead>
<tr><td><span class="left rad"><input name="option<?php echo $i;?>" type="radio" class="ex-radio" value="A"> </span><span class="left"><b>A. </b></span><span class="left"><?php echo $row['a'];?></span></td></tr>
<tr><td><span class="left rad"><input name="option<?php echo $i;?>" type="radio" class="ex-radio" value="B"> </span><span class="left"><b>B. </b></span><span class="left"><?php echo $row['b'];?></span></td></tr>
<tr><td><span class="left rad"><input name="option<?php echo $i;?>" type="radio" class="ex-radio" value="C"> </span><span class="left"><b>C. </b></span><span class="left"><?php echo $row['c'];?></span></td></tr>
<tr><td><span class="left rad"><input name="option<?php echo $i;?>" type="radio" class="ex-radio" value="D"> </span><span class="left"><b>D. </b></span><span class="left"><?php echo $row['d'];?></span></td></tr>
</table>
<hr>
<input type="hidden" id="answer<?php echo $i;?>" value="<?php echo $row['answer'];?>">
<div><button type="button" class="btn btn-info" onClick="answer('<?php echo $i;?>')">Check Answer</button> <span class="answer answer<?php echo $i;?>"> <?php echo $row['answer'];?> </span><span class="ansmsg<?php echo $i;?>"></span></div>
<hr>
<div><button type="button" class="btn btn-info" onClick="hint('<?php echo $i;?>')">Show Hint</button></div>
<div class="hint hint<?php echo $i;?>"><?php echo $row['showhint'];?></div>
</li>
<?php $i++;}?>
<li id="" class="page right" data-value="next"><i class="fa fa-toggle-right" data-toggle="tooltip" title="Next" data-placement="bottom"></i></li>
</ul>
</div>
</div>
</div><!-- /.box-body -->
</div><!-- /.box -->
<!-- /.box -->
</section><!-- /.content -->
</div></div><!-- /.content-wrapper -->
<?php footer();?>
</div><!-- ./wrapper -->
<?php jsfile();?>
<script type="text/javascript">
$(document).ready(function() {
function Display_Load() {
$("#load").fadeIn(1000, 0);
$("#load").html("<img src='load.gif' />");
}
function Hide_Load() {
$("#load").fadeOut('slow');
};
Display_Load();
$("#content").load("pagination.php?page=1", Hide_Load());
<?php $page; ?>
$("#paginate li").not('.page').click(function() {
Display_Load();
$("#paginate li").css({
}).css({
}).removeClass("active");
$(this).css({
}).css({
'border': 'none'
}).addClass("active");
var pageNum = this.id;
$("#content").load("pagination.php?page=" + pageNum, Hide_Load());
});
$("#paginate li.page").click(function() {
var page = $(this).attr("data-value");
if (page == "prev") {
var index = $("#paginate li.active").index();
if (index > 1) {
$("#paginate li.active").prev().trigger("click");
} else {
$("#paginate li.active").trigger("click");
}
} else {
var index = $("#paginate li.active").index();
if (index < $("#paginate li").length - 2) {
$("#paginate li.active").next().trigger("click");
} else {
$("#paginate li.active").trigger("click");
}
}
});
});
</script>
<script>
function answer(id){
if($("input[name='option"+id+"']:checked").val()) {
$(".answer"+id).show();
var radioValue = $("input[name='option"+id+"']:checked").val();
var answer=$("#answer"+id).val();
if(radioValue==answer){$(".ansmsg"+id).html('Your answer is correct!!').css({'color': '#00a65a'});}
else{$(".ansmsg"+id).html('Your answer is wrong!!').css({'color': '#dd4b39'});}
}
else{alert("Please select a option");}
}
function hint(id){
if($("input[name='option"+id+"']:checked").val()) {
$(".hint"+id).show();
}
else{alert("Please select a option");}
}
</script>
</body>
</html>
Zerion Mini Shell 1.0