<?php
include './header.php';
include './functions-img.php';
if (isset($_POST['save-date'])) {
foreach ($_POST['sort'] as $key => $img) {
$key = $key + 1;
$sql = "UPDATE `main-slider` SET `sort` = '" . $key . "' WHERE id = '" . $img . "'";
$db->readQuery($sql);
}
}
$gallery = getMainSliderPhotos();
?>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
<script>
$(function () {
$("#sortable").sortable();
$("#sortable").disableSelection();
});
</script>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Arrange Main Photos Slider </h3>
</div>
<form method="post">
<div class="panel-body">
<div class="row">
<div class="col-sm-12">
<ul id="sortable">
<?php
if (count($gallery) > 0) {
foreach ($gallery as $key => $img) {
?>
<li class="ui-state-default">
<span class="number-class">(<?php echo $key + 1; ?>)</span>
<img width="200px" class="example-image img-responsive" src="../images/slider/thumbForAdmin/<?php echo $img["image_name"]; ?>" alt=""/>
<input type="hidden" name="sort[]" value="<?php echo $img["id"]; ?>" class="sort-input"/>
</li>
<?php
}
} else {
?>
<b>No images in the database.</b>
<?php } ?>
</ul>
<div class="row">
<div class="col-sm-12 text-center" style="margin-top: 19px;">
<input type="submit" class="btn btn-info" id="btn-submit" value="Save Images" name="save-date">
</div>
</div>
</div>
</div>
</div>
</form>
</div>
<style>
#sortable { list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;}
#sortable li {
float: left;
padding: 2px;
margin: 3px;
cursor: move;
}
.number-class{
position: absolute;
background-color: white;
padding: 0px 2px 0px 1px;
border: solid 1px #8E8E8E;
border-radius: 3px;
margin: 1px;
font-size: 12px;
}
</style>
<?php
include './footer.php';
?>
|