Mini Shell

Direktori : /home/rizant5/public_html-1210/admin/
Upload File :
Current File : /home/rizant5/public_html-1210/admin/test-papers-edit.php

<?php 
require_once("../config.php");
?>
<?php
$id=$_GET['id'];
$data=$conn->prepare("select * from test_papers where id=$id");
$data->execute();$result=$data->fetchall();
foreach ($result as $key) {
$question = $key['question'];
$a = $key['a'];
$b = $key['b'];
$c = $key['c'];
$d = $key['d'];
$answer = $key['answer'];
$showhint = $key['showhint'];
$cou_id = $key['course_id'];
$sub_id = $key['subject'];
$chp_id = $key['chapter'];
$year = $key['year'];
}
if(isset($_POST['course_id'])){
  // include 'data.php';
  $chapter = $_POST['chapter'];
  $subject = $_POST['subject'];
  $course_id = $_POST['course_id'];
  $year = $_POST['year'];
  $question = $_POST['question'];
  $a = $_POST['a'];
  $b = $_POST['b'];
  $c = $_POST['c'];
  $d = $_POST['d'];
  $answer = $_POST['answer'];
  $showhint = $_POST['showhint'];
  $conn->exec("update test_papers SET chapter='$chapter',subject='$subject',course_id='$course_id',year='$year',question='$question',
  a='$a',b='$b',c='$c',d='$d',answer='$answer',showhint='$showhint' where id=$id");
  header("location:test-papers.php");
}

require_once("function-file.php");

require_once("function-menu.php");

cookiecheck();
?>

<!DOCTYPE html>

<html>

  <head>

    <meta charset="utf-8">

    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <title>Test Papers</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();datatablecss();?>

    <style>.selected{color:red;}</style>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
    <script type="text/javascript">
      $(document).ready(function(){
        $("#course").change(function(e){
            course_drop_down();
        });
      });
    </script>
    <script type="text/javascript">
      /*$(document).ready(function(){
        $("#subject").change(function(e){
          chapter_list_ajax();
        });

        course_drop_down();
        setTimeout(function(){
          $('#subject').val($('#subject').data('val'));
          chapter_list_ajax();
        },500);
        setTimeout(function(){
          $('#chapter').val($('#chapter').data('val'));
        },1500);
      });

      function chapter_list_ajax(){
        // e.preventDefault();
        var sid = $('#subject').val();
        $.post("dropdown.php",
        {
           subject: sid,   
        },
        function(data,status){
          $('#chapter').html(data);
        });
      }

      function course_drop_down(){
        // e.preventDefault();
        var cid = $('#course').val();
        $.post("dropdown.php",
        {
           course: cid,   
        },
        function(data,status){
          $('#subject').html(data);
          chapter_list_ajax();
        });
      }*/
    </script>

    <style type="text/css">
      .padd_top_20{ padding-top: 20px; }
    </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">
  <div class="col-sm-12">
    <section class="content">
      <div class="box">
        <div class="box-header with-border">
          <h3 class="box-title">Test Papers</h3>
        </div>
        <div class="box-body">
          <form action="" method="post" class="form-horizontal">
            <div class="form-group">
              <div class="col-sm-12">
                <div class="col-sm-3">
                  <label>Select Your Grade and Medium</label>
                  <select name="course_id" id="course" class="form-control" data-val="<?php echo $cou_id; ?>" required>
                    <?php 
                    $data=$conn->prepare("select * from courses");
                    $data->execute();$result=$data->fetchall();
                      foreach($result as $row){
                        if($row['course_id'] == $cou_id){
                          echo"<option value='$row[course_id]' selected>$row[course_name]</option>";
                        }else{
                          echo"<option value='$row[course_id]'>$row[course_name]</option>";
                        }
                      }
                    ?>
                  </select>
                </div>
                <div class="col-sm-3">
                  <label>Subject</label>
                  <!-- <select name="subject_id" id="subject" class="form-control" data-val="<?php echo $sub_id; ?>" required>
                    <option value="">Select Subject Name</option>
                  </select> --><br/>
                  <input type="text" name="subject" value="<?php echo $sub_id; ?>">
                </div>
                <div class="col-sm-3">
                  <label>Chapter</label>
                  <!-- <select name="chapter_id" id="chapter" class="form-control" data-val="<?php echo $chp_id; ?>" required>
                    <option value="">Select Chapter Name</option>
                  </select> --><br/>
                  <input type="text" name="chapter" value="<?php echo $chp_id; ?>">
                </div>
                <div class="col-sm-3">
                  <label>Select Year</label>
                  <select name="year" id="year" class="form-control" required>
                    <?php $current_year= date("Y");
                      $lower_year = 2010;
                      for ($current_year; $lower_year<=$current_year ; $current_year--){ 
                        if($current_year == $year){
                          echo "<option value='".$current_year."' selected>Year " .$current_year. "</option>";
                        }else{
                          echo "<option value='".$current_year."'>Year " .$current_year. "</option>";
                        }
                      }     
                    ?>
                  </select>      
                </div>
              </div>
            </div>
            <div class="form-group">
              <div class="col-sm-12 padd_top_20">
                <label for="question"> Question: </label>
                <!-- <input type="text" id="question" class="editors" name="question" value="<?php echo strip_tags($question,'<img>'); ?>" size="100" required> -->
                <textarea id="question" class="editors" name="question"><?php echo $question; ?></textarea>
              </div>
            </div>
            <div class="form-group">
              <div class="col-sm-12 padd_top_20">
                <div class="col-sm-6">
                  <label for="a"> A: </label>
                  <textarea id="a" class="editors" name="a"><?php echo $a; ?></textarea>
                </div>
                <div class="col-sm-6">
                  <label for="b"> B: </label>
                  <textarea id="b" class="editors" name="b"><?php echo $b; ?></textarea>
                </div>
              </div>
              <div class="col-sm-12 padd_top_20">
                <div class="col-sm-6">
                  <label for="c"> C: </label>
                  <textarea id="c" class="editors" name="c"><?php echo $c; ?></textarea>
                </div>
                <div class="col-sm-6">
                  <label for="d"> D: </label>
                  <textarea id="d" class="editors" name="d"><?php echo $d; ?></textarea>
                </div>  
              </div>
            </div>
            <div class="form-group">  
              <div class="col-sm-12 padd_top_20">
                <label for="answer"> Answer: </label>
                <!-- <input type="text" id="answer" name="answer" value= "<?php echo $answer; ?>" required> -->
                <select name="answer">
                    <option value="A" <?php if($answer == 'A'){ echo 'selected="selected"'; } ?>">A</option>
                    <option value="B" <?php if($answer == 'B'){ echo 'selected="selected"'; } ?>>B</option>
                    <option value="C" <?php if($answer == 'C'){ echo 'selected="selected"'; } ?>>C</option>
                    <option value="D" <?php if($answer == 'D'){ echo 'selected="selected"'; } ?>>D</option>
                  </select>
              </div>
            </div>
            <div class="form-group">
              <div class="col-sm-12 padd_top_20">
                <label for="showhint"> Showhint: </label>
                <textarea id="showhint" class="editors" name="showhint"><?php echo $showhint; ?></textarea>
              </div>
            </div>
            <div class="form-group">
              <div  class="col-sm-12" align="center">
                <button type="submit" name="save" class="btn btn-primary">Update Data</button>
              </div>
            </div>
          </form>     
        </div><!-- /.box-body -->
      </div><!-- /.box -->
    </section><!-- /.content -->
  </div>
</div></div><!-- /.content-wrapper -->

<?php footer();?>

</div><!-- ./wrapper -->

<?php jsfile();datatablejs();?>
<script src="//cdn.ckeditor.com/4.5.8/full/ckeditor.js"></script>
<script>
$(function() {
  $('.editors').each(function(){
    CKEDITOR.replace( $(this).attr('id') );
  });
});
</script>
</body>

</html>


Zerion Mini Shell 1.0