Mini Shell

Direktori : /home/rizant5/public_html/development/admin/
Upload File :
Current File : /home/rizant5/public_html/development/admin/read-topic.php

<?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");

}

if((!empty($_GET['action']))&&($_GET['action']=='delete')){

	$que_id=$_GET['que_id'];

	$conn->exec("delete from question where que_id='$que_id'");

	$conn->exec("delete from answers where que_id='$que_id'");

	header("location:read-topic.php?topic_id=$topic_id#questions");

}

if((!empty($_GET['action']))&&($_GET['action']=='answer')){

	$ans_id=$_GET['ans_id'];

	$conn->exec("delete from answers where ans_id='$ans_id'");

	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>
    iframe{width: 100% !Important;}.ans-text{background-color: #f5f5f5;border: 1px solid #ccc;padding: 10px;}
    .img-thumbnail img {
      height: auto !important;
      max-width: 100%;
    }
</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 class="col-sm-5 img-thumbnail col-xs-12"><?php echo $result['topic_desc'];?></div>

                    <div class="col-sm-6 img-thumbnail col-sm-offset-1 col-xs-12"><?php echo $result['video_url'];?></div>

              </div>

            </div><!-- /.box-body -->

          </div><!-- /.box -->

          <div class="box box-primary">

          	<div class="box-body">

           <form action="#" method="post">

              <div class="row form-group" id="questions">      

                    <div class="col-sm-12">

              <!-- The time line -->

              <ul class="timeline">

                <!-- timeline time label -->

                <?php $db=$conn->prepare("select * from question a inner join student_reg b on a.stu_id=b.stu_id where a.topic_id='$topic_id' order by datetime DESC");

				$db->execute();$results=$db->fetchall();

				foreach($results as $rows){?>

                <!-- timeline item -->

                <li>

                  <i class="fa fa-envelope bg-blue"></i>

                  <div class="timeline-item">

                    <span class="time "><a href='read-topic.php?action=delete&que_id=<?php echo $rows['que_id'];?>' onclick="return confirm('Are you sure you want to delete?')" class="btn btn-danger btn-xs">Delete</a>&nbsp;&nbsp;<?php echo date('d M. Y',strtotime($rows['datetime']));?> - <i class="fa fa-clock-o"></i>  <?php echo date('h:i A',strtotime($rows['datetime']));?></span>

                    <h3 class="timeline-header"><?php echo $rows['stu_name'];?></h3>

                    <div class="timeline-body">

                      <?php echo $rows['text'];?>

                    </div>

                    <?php $data=$conn->prepare("select * from answers where que_id='$rows[que_id]'");$i=1;

					$data->execute();$result=$data->fetchall();$num=$data->rowcount();if($num>0){

						foreach($result as $row){?>

                    <div class="timeline-footer">

                    <?php if($i==1){?><span class="badge bg-green">Answer</span><?php }?>&nbsp;&nbsp;<a href='read-topic.php?action=answer&ans_id=<?php echo $row['ans_id'];?>' onclick="return confirm('Are you sure you want to delete?')" class="btn btn-danger btn-xs">Delete this answer</a>

                    <p><div class='ans-text'><?php echo $row['text'];?></div></p>

                    </div><?php $i++;}}?>

                    <div class="row form-group" style="padding: 10px 10px;"><div class="col-sm-12" align="center"><textarea class="form-control" placeholder="Type your answer..." id="ans_<?php echo $rows['que_id']; ?>"></textarea></div></div>

                    <div class="row form-group"><div class="col-sm-12" align="center"><button type="button" onClick="saveme('<?php echo $rows['que_id']; ?>')" name="save" class="btn btn-success">Submit Answer</button></div></div>

                    <hr>

                  </div>

                </li>

                <!-- END timeline item -->

                <!-- timeline item -->

                <?php }?>

                <!-- END timeline item -->

               

              </ul>

              </div>

            </div>

            </div>

            </form>

          </div><!-- /.box -->

        </section><!-- /.content -->

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

      <?php footer();?>

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

   <?php jsfile();ratenum();?>

   <script>

   function saveme(id){

   		var answer=$("#ans_"+id).val();

		$.ajax({

		type: 'post',

		url: 'update-answer.php',

		data: {'id':id,'answer':answer},

	  	success: function (data) {

			window.location.reload();

        }

     });

   }

   </script>

  </body>

</html>


Zerion Mini Shell 1.0