Mini Shell

Direktori : /home/rizant5/public_html-1210/admin/
Upload File :
Current File : /home/rizant5/public_html-1210/admin/practice.php

<?php 
require_once("../config.php");
require_once("function-file.php");
require_once("function-menu.php");
cookiecheck();
$topic_id=$_GET['topic_id'];
$subid=$_GET['subid'];
if(isset($_POST['save'])){
	$practice_id=array();
	$practice_id=$_POST['practice_id'];
	$novalue=array();
	$novalue=$_POST['novalue'];
	$question=array();
	$question=$_POST['question'];
	$a=array();
	$a=$_POST['a'];
	$b=array();
	$b=$_POST['b'];
	$c=array();
	$c=$_POST['c'];
	$d=array();
	$d=$_POST['d'];
	$answer=array();
	$answer=$_POST['answer'];
	$showhint=array();
	$showhint=$_POST['showhint'];
	$count=count($question);
	for($i=0;$i<$count;$i++){
		if($novalue[$i]=='novalue'){
			$conn->exec("insert into practice (topic_id,question,a,b,c,d,answer,showhint) values ('$topic_id','$question[$i]','$a[$i]','$b[$i]','$c[$i]','$d[$i]','$answer[$i]','$showhint[$i]')");
		}else{
			$conn->exec("update practice SET question='$question[$i]',a='$a[$i]',b='$b[$i]',c='$c[$i]',d='$d[$i]',answer='$answer[$i]',showhint='$showhint[$i]' where practice_id='$practice_id[$i]'");
		}
	}
	header("location:chapters.php?subid=$subid");
}
?>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Set Practice Paper</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();?>
  </head>
  <body class="hold-transition skin-blue layout-top-nav">
    <!-- Site wrapper -->
    <div class="wrapper">
<?php headermenu();jsfile();?>
<script src="//cdn.ckeditor.com/4.5.8/full/ckeditor.js"></script>
      <!-- =============================================== -->
      <!-- 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">Set Practice Paper</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">
            <form action="#" method="post" role="form" class="form-horizontal">
              
              <h4>Create Practice Paper</h4>
               
<div class="form-group">
              		<div class="col-sm-12">
                        <table align="center" class="table order-list th" id="myTable">
						<?php $data=$conn->prepare("select * from practice where topic_id='$topic_id'");$i=1;
						$data->execute();$result=$data->fetchall();
                       foreach($result as $row){?><input type='hidden' name='practice_id[]' value='<?php echo $row['practice_id'];?>'><tbody><tr><td><label>Question &nbsp;&nbsp;<button type='button' id='ibtnDel' class='btn btn-danger btn-xs'><i class='fa fa-trash'></i>&nbsp;Remove this question</button></label><textarea name='question[]' id='question<?php echo $i;?>' class='form-control' required><?php echo $row['question'];?></textarea></td></tr><tr><td><label>A.</label><textarea name='a[]' id='a<?php echo $i;?>' class='form-control' required><?php echo $row['a'];?></textarea></td></tr><tr><td><label>B.</label><textarea name='b[]' id='b<?php echo $i;?>' class='form-control' required><?php echo $row['b'];?></textarea></td></tr><tr><td><label>C.</label><textarea name='c[]' id='c<?php echo $i;?>' class='form-control'  required><?php echo $row['c'];?></textarea></td></tr><tr><td><label>D.</label><textarea name='d[]' id='d<?php echo $i;?>' class='form-control' required><?php echo $row['d'];?></textarea></td></tr><tr><td><label>Answer</label><select name='answer[]' type='text' class='form-control'><option <?php if($row['answer']=='A'){echo "selected";}?>>A</option><option<?php if($row['answer']=='B'){echo "selected";}?>>B</option><option <?php if($row['answer']=='C'){echo "selected";}?>>C</option><option <?php if($row['answer']=='D'){echo "selected";}?>>D</option></select></td></tr><tr><td><label>Show to how</label><textarea name='showhint[]' id='editor<?php echo $i;?>'  class='form-control editorss' rows='4'><?php echo $row['showhint'];?></textarea></td></tr><tr><td></td></tr></tbody>
					 <script>
	  CKEDITOR.replace( $("#question<?php echo $i;?>").attr('id') );
	  CKEDITOR.replace( $("#a<?php echo $i;?>").attr('id') );
	  CKEDITOR.replace( $("#b<?php echo $i;?>").attr('id') );
	  CKEDITOR.replace( $("#c<?php echo $i;?>").attr('id') );
	  CKEDITOR.replace( $("#d<?php echo $i;?>").attr('id') );
	  CKEDITOR.replace( $("#editor<?php echo $i;?>").attr('id') );
</script><input type='hidden' name='novalue[]' value='value'><?php $i++;}?>
						
                        </table>
                        <button type="button" id="addrow" class="btn btn-info btn-sm"><i class='fa fa-plus'></i> Add New Question</button>
<fieldset class="form-group" >
                     </div>
			</div>
            
              <div class="form-group">
              		<div class="col-sm-12" align="right">
                    <button type="reset"  class="btn btn-default" rows="4">Reset</button>&nbsp;&nbsp;
                    <button  type="submit" name="save" class="btn btn-success" >Save</button></div>
              </div>
            </div><!-- /.box-body -->
          </div><!-- /.box -->
        </section><!-- /.content -->
      </div></div><!-- /.content-wrapper -->
      <?php footer();?>
    </div><!-- ./wrapper -->
   <?php ratenum();?>

    <!---->
    <script>
         $(document).ready(function () {
                                               var i="<?php echo $i;?>";
                                                var counter1 = 0;
                                                $("#addrow").on("click", function () {
                                                var counter = $('#myTable tr').length - 10;
                                                var newRow = $("<tbody><tr><td colspan='2'>&nbsp;</td></tr>");
                                                var cols = "<input type='hidden' name='novalue[]' value='novalue'><tr><td><label>Question &nbsp;&nbsp;<button type='button' id='ibtnDel' class='btn btn-danger btn-xs'><i class='fa fa-trash'></i>&nbsp;Remove this question</button></label><textarea name='question[]' id='question"+i+"' class='form-control' required></textarea></td></tr><tr><td><label>A.</label><textarea name='a[]' id='a"+i+"'  class='form-control' required></textarea></td></tr><tr><td><label>B.</label><textarea name='b[]' id='b"+i+"' class='form-control' required></textarea></td></tr><tr><td><label>C.</label><textarea name='c[]' id='c"+i+"' class='form-control' required></textarea></td></tr><tr><td><label>D.</label><textarea name='d[]' id='d"+i+"' class='form-control' required></textarea></td></tr><tr><td><label>Answer</label><select name='answer[]' type='text' class='form-control'><option>A</option><option>B</option><option>C</option><option>D</option></select></td></tr><tr><td><label>Show to how</label><textarea name='showhint[]' id='editor"+i+"'  class='form-control editorss' rows='4'></textarea></td></tr><tr><td></td></tr>";
										        									
                                                newRow.append(cols);
												$("table.order-list").append(newRow);
												counter1++;
												CKEDITOR.replace( $("#question"+i).attr('id') );CKEDITOR.replace( $("#a"+i).attr('id') );CKEDITOR.replace( $("#b"+i).attr('id') );CKEDITOR.replace( $("#c"+i).attr('id') );CKEDITOR.replace( $("#d"+i).attr('id') );CKEDITOR.replace( $("#editor"+i).attr('id') );
												i++;	
												});
													$("table.order-list").on("click", "#ibtnDel", function (event) {
													i--;
													$(this).closest("tbody").remove();
													calculateGrandTotal();
												});
											});
											
                                              </script>


  
  </body>
</html>

Zerion Mini Shell 1.0