<?php include ("connection/conn.php");

$select="select * from reviews_tbl where id='".$_REQUEST['id']."'";
$query=mysqli_query($link,$select);
$assoc=mysqli_fetch_assoc($query);

	if(isset($_POST['submit']))
		{
		
		$description=addslashes($_POST['description']);
		 $name=$_POST['name'];
		$course_category=$_POST['course_category'];
			if($name=="")
			{
				$Error_msg="Please enter name.<br>";
			}
			 if($_FILES['img']['name']!="")
			{
                $img=$_FILES['img']['name'];
                $tenthorgext=substr(strrchr($img,"."),1);
                $img=date('d-m-Yhis').rand(0,9999).'.'.$tenthorgext;
                $upload_path_img=$_FILES['img']['tmp_name'];	
               copy($upload_path_img,"../listblg/".$img);
            }
			else if($_FILES['img']['name']=="")
			{
				$img=$assoc['img'];
			}
			if($Error_msg=="")
			{	
			  $updateBlog="update reviews_tbl set description='".$description."',course_category='".$course_category."',name='".$name."',img='".$img."' where id='".$_REQUEST['id']."' ";
			mysqli_query($link,$updateBlog);
			header("location:manage-reviews.php?success=reviews has been Update sucessfully.");
			exit();
			}
		}
?>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>Administrator</title>
		<link href="css/bootstrap.css" rel="stylesheet" />
		<link href="css/style.css" rel="stylesheet" />
		<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
		
	<script src="vendors/modernizr-2.6.2-respond-1.1.0.min.js"></script>
	</head>
	
	<body>
		<div id="wrapper">
			<?php
				include("top-header.php");
				include("right-sec.php");
			?>
			<div id="page-wrapper" >
				<div id="page-inner">
					<div class="row">
						<div class="col-md-12">
							<h3 class="page-header">
								Update Reviews  <small></small>
							</h3>
							<div class="table-sec">
								<div class="srch_box">
									<form name="pnews" method="post" action="" enctype="multipart/form-data">
										<div class="row">
											
											<div class="col-md-12 col-xs-12">
												<div class="pnl_box"> 
													<div class="col-md-12 col-xs-6">	
														<div class="form-group form-select">
															<label>Class Category <span>*</span></label>
														<select name="course_category" class="form-control">
																<option value="<?php echo $assoc['course_category'];?>"><?php echo $assoc['course_category'];?></option>
																<?php
							$sqlcourse="select * from course_category order by id asc";
		                    $resultcourse=mysqli_query($link,$sqlcourse);
																while($findcporse=mysqli_fetch_array($resultcourse)){?>
																<option value="<?php echo $findcporse['course']?>"><?php echo $findcporse['course']?></option>
																<?php } ?>
															</select>
														</div>		
													</div>
													
														<div class="col-md-12 col-xs-6">	
														<div class="form-group form-select">
															<label>Name <span>*</span></label>
															<input class="form-control" type="text"  name="name" value="<?php echo $assoc['name'];?>">
														</div>		
													</div>
													
												
													<div class="col-md-12 col-xs-6">	
														<div class="form-group form-select">
															<label>Description<span>*</span></label>
															<textarea name="description"  rows="5" cols="10" id="ckeditor_full" ><?php echo $assoc['description'];?></textarea>
														</div>		
													</div>
													<div class="col-md-12 col-xs-6">	
														<div class="form-group form-select">
															<label>Image <span>*</span></label>
															<input class="form-control" type="file"  name="img"><img src="/listblg/<?php echo $assoc['img'];?>" height="50" width="50"  />
														</div>		
													</div>
													
												</div>	
												
											</div>
										</div>
										<div class="row">
											<div class="col-md-4 col-xs-4">	
												<div class="btn_sec">
														<input type="submit" name="submit" value="Submit" />
												</div>
											</div>
										</div>
									</form>
								</div>
							</div>
						</div>
					</div> 
				</div>
			</div>
			<div style="height:70px; clear:both">&nbsp;</div>
			<footer class="footer-sec">
				<div class="container">
					<div class="row">
						<div class="col-md-12">
							<p class="text-center">All right reserved. Template Design by: <a href="">Anshul Chittouria</a></p>
						</div>
					</div>
				</div>
			</footer>
		</div>
		
<!-- jQuery Js -->
		<script src="js/jquery-1.10.2.js"></script>
		<script src="js/bootstrap.min.js"></script>
		<script src="js/jquery.metisMenu.js"></script>
		<script src="js/custom-scripts.js"></script>
		<script src="vendors/jquery.validate.js" type="text/javascript"></script>
<script src="vendors/cms.js" type="text/javascript"></script>
<!--/.fluid-container-->
<link href="vendors/datepicker.css" rel="stylesheet" media="screen">
<link href="vendors/uniform.default.css" rel="stylesheet" media="screen">
<link href="vendors/chosen.min.css" rel="stylesheet" media="screen">
<link href="vendors/wysiwyg/bootstrap-wysihtml5.css" rel="stylesheet" media="screen">
<s<script src="vendors/wysiwyg/wysihtml5-0.3.0.js"></script>
<script src="vendors/wysiwyg/bootstrap-wysihtml5.js"></script>
<script src="vendors/wizard/jquery.bootstrap.wizard.min.js"></script>
<script src="assets/scripts.js"></script>
<script src="vendors/ckeditor/ckeditor.js"></script>
<script src="vendors/ckeditor/adapters/jquery.js"></script>
<script>
$(function() {
	// Bootstrap
	$('#bootstrap-editor').wysihtml5();

	// Ckeditor standard
	$( 'textarea#ckeditor_standard' ).ckeditor({width:'98%', height: '150px', toolbar: [
		{ name: 'document', items: [ 'Source', '-', 'NewPage', 'Preview', '-', 'Templates' ] },	// Defines toolbar group with name (used to create voice label) and items in 3 subgroups.
		[ 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo' ],			// Defines toolbar group without name.
		{ name: 'basicstyles', items: [ 'Bold', 'Italic' ] }
	]});
	$( 'textarea#ckeditor_full' ).ckeditor({width:'98%', height: '150px'});
});
</script>
	</body>
</html>
