File: /var/www/nclive/technc/ckeditor/list_institute_course.php
<?php
include 'config.php';
$count="select count(*) as total from sp_exam_category";
$sql=$db->prepare($count);
$sql->execute();
$plus=$sql->fetch();
$query="Select ic.id,ic.institute_id,ic.course_id,i.institutions_name,GROUP_CONCAT(c.course_name) as cname from sp_institute_courses as ic
left join sp_institutions as i on i.id=ic.institute_id
left join sp_courses as c on c.id=ic.course_id
";
$sql=$db->prepare($query);
$sql->execute();
?>
<!DOCTYPE html>
<!--[if IE 9]><html class="ie9 no-focus" lang="en"> <![endif]-->
<!--[if gt IE 9]><!--> <html class="no-focus" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<title>Sarkari Pariksha - Dashboard</title>
<meta name="description" content="">
<meta name="author" content="pixelcave">
<meta name="robots" content="noindex, nofollow">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<!-- Icons -->
<!-- The following icons can be replaced with your own, they are used by desktop and mobile browsers -->
<link rel="shortcut icon" href="assets/img/favicons/favicon.png">
<link rel="icon" type="image/png" href="assets/img/favicons/favicon-16x16.png" sizes="16x16">
<link rel="icon" type="image/png" href="assets/img/favicons/favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="assets/img/favicons/favicon-96x96.png" sizes="96x96">
<link rel="icon" type="image/png" href="assets/img/favicons/favicon-160x160.png" sizes="160x160">
<link rel="icon" type="image/png" href="assets/img/favicons/favicon-192x192.png" sizes="192x192">
<link rel="apple-touch-icon" sizes="57x57" href="assets/img/favicons/apple-touch-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="assets/img/favicons/apple-touch-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="assets/img/favicons/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="assets/img/favicons/apple-touch-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="assets/img/favicons/apple-touch-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="assets/img/favicons/apple-touch-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="assets/img/favicons/apple-touch-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="assets/img/favicons/apple-touch-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="assets/img/favicons/apple-touch-icon-180x180.png">
<!-- END Icons -->
<!-- Stylesheets -->
<!-- Web fonts -->
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400italic,600,700%7COpen+Sans:300,400,400italic,600,700">
<!-- Page JS Plugins CSS -->
<link rel="stylesheet" href="assets/js/plugins/slick/slick.min.css">
<link rel="stylesheet" href="assets/js/plugins/slick/slick-theme.min.css">
<!-- Bootstrap and OneUI CSS framework -->
<link rel="stylesheet" href="assets/css/bootstrap.min.css">
<link rel="stylesheet" id="css-main" href="assets/css/oneui.css">
<style>
.text-capitalize{
text-transform:none;
}
#chk{
margin-bottom: -28px;
margin-left: -106px;
}
</style>
<!-- You can include a specific file from css/themes/ folder to alter the default color theme of the template. eg: -->
<!-- <link rel="stylesheet" id="css-theme" href="assets/css/themes/flat.min.css"> -->
<!-- END Stylesheets -->
</head>
<body>
<!-- Page Container -->
<!--
Available Classes:
'enable-cookies' Remembers active color theme between pages (when set through color theme list)
'sidebar-l' Left Sidebar and right Side Overlay
'sidebar-r' Right Sidebar and left Side Overlay
'sidebar-mini' Mini hoverable Sidebar (> 991px)
'sidebar-o' Visible Sidebar by default (> 991px)
'sidebar-o-xs' Visible Sidebar by default (< 992px)
'side-overlay-hover' Hoverable Side Overlay (> 991px)
'side-overlay-o' Visible Side Overlay by default (> 991px)
'side-scroll' Enables custom scrolling on Sidebar and Side Overlay instead of native scrolling (> 991px)
'header-navbar-fixed' Enables fixed header
-->
<div id="page-container" class="sidebar-l sidebar-o side-scroll header-navbar-fixed">
<!-- Header -->
<header id="header-navbar" class="content-mini content-mini-full">
<!-- Header Navigation Left -->
<ul class="nav-header pull-left">
<li class="hidden-md hidden-lg">
<!-- Layout API, functionality initialized in App() -> uiLayoutApi() -->
<button class="btn btn-default" data-toggle="layout" data-action="sidebar_toggle" type="button">
<i class="fa fa-navicon"></i>
</button>
</li>
<li class="hidden-xs hidden-sm">
<!-- Layout API, functionality initialized in App() -> uiLayoutApi() -->
<button class="btn btn-default" data-toggle="layout" data-action="sidebar_mini_toggle" type="button">
<i class="fa fa-ellipsis-v"></i>
</button>
</li>
<li>
<!-- Opens the Apps modal found at the bottom of the page, before including JS code -->
<button class="btn btn-default pull-right" data-toggle="modal" data-target="#apps-modal" type="button">
<i class="si si-grid"></i>
</button>
</li>
<li class="visible-xs">
<!-- Toggle class helper (for .js-header-search below), functionality initialized in App() -> uiToggleClass() -->
<button class="btn btn-default" data-toggle="class-toggle" data-target=".js-header-search" data-class="header-search-xs-visible" type="button">
<i class="fa fa-search"></i>
</button>
</li>
<li class="js-header-search header-search">
<form class="form-horizontal" method="post">
<div class="form-material form-material-primary input-group remove-margin-t remove-margin-b">
<input class="form-control" type="text" id="base-material-text" name="base-material-text" placeholder="Search..">
<span class="input-group-addon"><i class="si si-magnifier"></i></span>
</div>
</form>
</li>
</ul>
<!-- END Header Navigation Left -->
</header>
<!-- END Header -->
<!-- Main Container -->
<main id="main-container">
<div class="content content-narrow">
<!-- Forms Row -->
<div class="row">
<div class="col-lg-12">
<!-- Bootstrap Forms Validation -->
<h2 class="content-heading">Exam Category List</h2>
<table class="table table-striped table-hover text-capitalize">
<thead>
<tr class="danger">
<th class="text-center">S.no</th>
<th class="text-center">Institute name</th>
<th class="text-center">Course name</th>
<th class="text-center">Edit</th>
<th class="text-center">Delete</th>
</tr>
</thead>
<?php $i='1';
while($row=$sql->fetch()){
$com=$row['course_id'];
$ini=$row['institute_id'];
?>
<tr>
<td class="text-center"><?php echo $i; ?></td>
<td class="text-center"><?php echo $row['institutions_name']; ?></td>
<td class="text-center"><?php echo $row['cname']; ?></td>
<td class="text-center"><button name="edit" class="btn btn-info" onClick="selectData(<?php echo $row['institute_id']; ?>)" data-toggle="tooltip" title="Edit this exam">Edit</button></td>
<td class="text-center"><a style="color:#fff;" href="delete.php?id=<?php echo $row['institute_id'];?>" onClick="return confirm('Are you sure you want to delete')"><button class="btn btn-danger" data-toggle="tooltip" title="Delete this exam!" data-placement="bottom">Delete</button></a></td>
</tr>
<?php $i++; } ?>
<tr class="danger">
<th colspan='4'>Total Category</th>
<td colspan='4'><?php echo $plus['total']; ?></td>
</tr>
</table>
<!-- Bootstrap Forms Validation -->
</div>
</div>
</div>
<!-- END Forms Row -->
</div>
<?php
if(isset($_REQUEST['submit'])){
echo $id=$_REQUEST['id'];
//$insti=$_REQUEST['ins'];
$course=$_REQUEST['cour'];
print_r($course);
print_r($id);
foreach($course as $c){
$query1="Update sp_institute_courses set course_id='$c' where institute_id='$id'";
$sql1 = $db->prepare($query1);
$sql1->execute();
echo '<h3 style="color:green;">Data Update successfully</h3>';
// echo "<meta http-equiv='refresh' content='0'>";
}
}
?>
<!-------STATUS MODEL------------------------------->
<div class=" modal fade" id="statusModel" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Do you want to change status ? </h4>
</div>
<div class="modal-body">
<form class="js-validation-bootstrap form-horizontal" method="post" action="" enctype="multipart/form-data" id="serial">
<div class="form-group">
<label class="col-md-4 control-label" for="val-username">Name<span class="text-danger">*</span></label>
<div class="col-md-7">
<input type="hidden" name="id" id="id">
<select class="js-select2 form-control" name="ins" style="width: 100%;">
<?php
$sql8 = $db->prepare("SELECT id,institutions_name FROM sp_institutions");
$sql8->execute();
?><option selected="selected" id="ins">--Select Institute--</option><?php
while($row8=$sql8->fetch(PDO::FETCH_ASSOC))
{
?>
<option value="<?php echo $row8['id']; ?>"><?php echo $row8['institutions_name']; ?></option>
<?php
} ?>
</select>
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label" for="val-password">Course name<span class="text-danger">*</span></label>
<div class="col-md-10">
<?php
echo $jk="select count(*) from sp_institute_courses where course_id='$com'";
$check=$db->prepare("select count(*) from sp_institute_courses where course_id='$com'");
$check->execute();
$count=$check->rowCount();
print_r($count);
if($count==1){
$checked = "checked";
} else {
$checked = "";
}
$cou=$db->prepare("select id,course_name from sp_courses order by id asc");
$cou->execute();
while($row3=$cou->fetch(PDO::FETCH_ASSOC)){
?>
<div class="col-md-4"><input <?php echo $checked; ?> class="form-control" type="checkbox" name="cour[]" value="<?php echo $row3['id']; ?>"><?php echo $row3['course_name']; ?>
</div>
<?php } ?>
</div>
</div>
<div class="form-group">
<div class="col-md-10 col-md-offset-2">
<button class="btn btn-lg btn-primary" type="submit" name="submit">Submit</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<!---------END STATUS MODEL----->
<!-- END Page Content -->
</main>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script type="text/javascript">
function selectData(id) {
// alert(id);
$.ajax('list_institute_course_select.php', {
type: 'POST', // http method
data: { id:id }, // data to submit
success: function (data, status, xhr) {
console.log(data);
//console.log("njkj");
//console.log(data[0]);
document.getElementById('id').value = data.institute_id;
document.getElementById('ins').innerHTML = data.institutions_name;
//document.getElementById('chk').value=data.course_id;
//document.getElementById("img").files[0].name;
},
error: function (jqXhr, textStatus, errorMessage) {
}
});
jQuery("#statusModel").modal();
// body...
}
</script>
<?php include 'footer.php'; ?>
<!-- END Main Container -->