File: /var/www/nclive/technc/add_latest_updates_old1.php
<?php
include 'header.php';
$user_id =$_SESSION['user_id'];
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL)
?>
<style>
#form .form-group label.error {
color: #FB3A3A;
display: inline-block;
margin: 0px 0 0px 0px;
padding: 0;
}
.form-horizontal .control-label{
text-align:left !important;
}
</style>
<main id="main-container">
<div class="content content-narrow">
<div class="row">
<div class="col-lg-12">
<h2 class="content-heading">Add Latest Updates Entity Order</h2>
<?php
$curDate = date('Y-m-d H:i:s');
if(isset($_REQUEST['Add'])){
//print_r($_REQUEST);
//die();
$examname=$_REQUEST['examname'];
$Update_exam=$db->prepare("UPDATE sp_exam SET top_display_order='0',add_by='$user_id',add_date='$curDate'");
//echo "UPDATE sp_exam SET top_display_order='0',add_by='$user_id',add_date='$curDate'";
// $Update_exam->execute();
$Update_link=$db->prepare("UPDATE sp_exam_links SET display_entity='0',update_by='$user_id',update_date='$curDate'");
//echo "UPDATE sp_exam_links SET display_entity='0',update_by='$user_id',update_date='$curDate'";
// $Update_link->execute();
foreach($_REQUEST['examname'] as $exam_id)
{
echo $entity = $_REQUEST['entity'.$exam_id];
$display_order = $_REQUEST['display_order'.$exam_id];
$updatelink2=$db->prepare("UPDATE sp_exam_links SET display_entity='1',update_by='$user_id',update_date='$curDate' where entity_id='$entity' and exam_id='$exam_id'");
//echo "UPDATE sp_exam_links SET display_entity='1',update_by='$user_id',update_date='$curDate' where entity_id='$entity' and exam_id='$exam_id'";
// $updatelink2->execute();
$Updateexam=$db->prepare("UPDATE sp_exam SET top_display_order='$display_order', add_by='$user_id',add_date='$curDate' where exam_id='$exam_id'");
//echo "UPDATE sp_exam SET top_display_order='$display_order', add_by='$user_id',add_date='$curDate' where exam_id='$exam_id'";
// $Updateexam->execute();
}
}
?>
<div class="block">
<div class="block-header">
<ul class="block-options">
<li>
<button type="button"><i class="si si-settings"></i></button>
</li>
</ul>
<h3 class="block-title"></h3>
</div>
<div class="block-content block-content-narrow">
<form class="js-validation-bootstrap form-horizontal" method="post" id="form">
<div class="form-group">
<label class="col-md-4 control-label" for="val-select2">Select Exam</label>
<label class="col-md-4 control-label" for="val-select2">Select Entity</label>
<label class="col-md-4 control-label" for="val-select2">Display Order</label>
</div>
<?php
$select_entity = $db->prepare("SELECT exam.exam_id,exam.exam_name,links.entity_id,entity.name,exam.top_display_order FROM sp_exam AS exam LEFT JOIN sp_exam_links AS links ON links.exam_id=exam.exam_id LEFT JOIN sp_exam_entity AS entity ON entity.id=links.entity_id WHERE exam.top_display_order !='' AND links.display_entity !='0' AND exam.status='1' AND links.status='1' ORDER BY exam.top_display_order ASC LIMIT 8");
$select_entity->execute();
while($myrow=$select_entity->fetch(PDO::FETCH_ASSOC)){ ?>
<div class="form-group">
<div class="col-md-4">
<select class="js-select2 form-control" name="examname[]" style="width: 100%;" onchange="entity();" id="exam_id">
<?php
$sql = $db->prepare("SELECT exam_id,exam_name FROM sp_exam WHERE status='1' ORDER BY exam_name ASC");
$sql->execute(); ?>
<?php while($row=$sql->fetch(PDO::FETCH_ASSOC)){ ?>
<option value="<?php echo $row['exam_id']; ?>" <?php if($row['exam_id']==$myrow['exam_id']){echo "selected";} ?>><?php echo $row['exam_name']; ?></option>
<?php } ?>
</select>
</div>
<div class="col-md-4">
<select class="js-select2 form-control entity" name="entity<?php echo $myrow['exam_id']; ?>" style="width: 100%;" id="entity<?php echo $myrow['exam_id']; ?>">
<option value="<?php echo $myrow['entity_id']; ?>"> <?php echo $myrow['name']; ?> </option>
</select>
</div>
<div class="col-md-4">
<input class="form-control" type="text" name="display_order<?php echo $myrow['exam_id']; ?>" value="<?php echo $myrow['top_display_order']; ?>">
</div>
</div>
<?php } ?>
<div class="form-group">
<div class="col-md-5"></div>
<div class="col-md-2">
<button class="btn btn-lg btn-primary" type="submit" name="Add">Add</button>
</div>
<div class="col-md-5"></div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</main>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css" />
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
<script type="text/javascript">
function entity(id)
{
var id = jQuery("#exam_id").val();
alert(id);
var site = "get_entity.php?id="+id;
jQuery.ajax({
url: site,
type:'POST',
data:'html',
success:function(data){
jQuery(".entity").class('new_class' +id );
document.getElementById(".new_class"+id).innerHTML = data;
}
});
}
</script>
<?php include 'footer.php'; ?>