Viewing file: view-blog.php (6.93 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
error_reporting(0);
include 'conn.php';
require_once "auth.php";
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title><?php include('title.php') ?></title>
<link rel="shortcut icon" type="image/png" href="images/fav.png">
<link rel="stylesheet" href="plugins/fontawesome-free/css/all.min.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/themify-icons.css">
<link rel="stylesheet" href="css/animate.css">
<link rel="stylesheet" href="css/styles.css">
<link rel="stylesheet" href="css/red.css" id="style_theme">
<link rel="stylesheet" href="css/responsive.css">
<link rel="stylesheet" href="charts/css/morris.css">
<link rel="stylesheet" href="css/jquery-jvectormap.css">
<link rel="stylesheet" href="datatable/dataTables.bootstrap4.min.css">
<link rel="stylesheet" href="plugins/summernote/summernote-bs4.css">
<script src="js/modernizr.min.js"></script>
<link rel="stylesheet" href="dist/css/user_css.css">
</head>
<body>
<!-- Pre Loader -->
<div class="loading">
<div class="spinner">
<div class="double-bounce1"></div>
<div class="double-bounce2"></div>
</div>
</div>
<!--/Pre Loader -->
<div class="wrapper">
<!-- Sidebar -->
<?php include('sidebar.php') ?>
<!-- /Sidebar -->
<!-- Page Content -->
<div id="content">
<div>
<?php include('topbar.php') ?>
</div>
<?php
if(isset($_GET['delete_id']))
{
$del = $_GET['delete_id'];
// Retrieve the blog details
$selectdelete = mysqli_query($con,"SELECT * FROM blog WHERE id = ".$del."");
$selectimg = mysqli_fetch_array($selectdelete);
// Delete the associated comments
$query_delete_comment = "DELETE FROM comments WHERE blog_id = '".$del."'";
$p_delete_comment = mysqli_query($con, $query_delete_comment);
// Delete the blog entry and image
$path = 'images/blog/';
$now_delete = unlink($path.$selectimg['img']);
$path = 'images/blog/';
$now_delete = unlink($path.$selectimg['sub_image1']);
if($now_delete){
$query_delete = "DELETE FROM blog WHERE id = '".$del."'";
$p_delete = mysqli_query($con, $query_delete);
if ($p_delete) {
echo "<script>alert('Deleted Successfully');</script>";
echo "<script>window.location.href = 'view-blog.php';</script>";
} else {
echo "<script>alert('Deletion Failed');</script>";
}
}
}
$limit = 10;
if (isset($_GET["page"])) {
$page = $_GET["page"];
}
else{
$page=1;
};
$serial = ($page-1) * $limit;
$resultt = mysqli_query($con,"SELECT * FROM blog ORDER BY id DESC LIMIT $serial, $limit");
?>
<div class="row no-margin-padding">
<div class="col-md-6">
<h3 class="block-title">Training</h3>
</div>
<div class="col-md-6">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="index.html">
<span class="ti-home"></span>
</a>
</li>
<li class="breadcrumb-item">Blog View</li>
</ol>
</div>
</div>
<section class="content-header">
<div class="container-fluid">
<div class="row mb-2 justify-content-center">
<div class="col-sm-6">
<h1>View training / ویرایش آموزش</h1>
</div>
</div>
</div>
</section>
<section class="content">
<div class="row justify-content-center">
<div class="col-md-12">
<div class="card card-info">
<div class="card-header">
<h3 class="card-title">View</h3>
<div class="card-tools">
<button type="button" class="btn btn-tool" data-card-widget="collapse" data-toggle="tooltip" title="Collapse">
<i class="fas fa-minus"></i></button>
</div>
</div>
<div class="card-body p-0">
<table class="table">
<thead>
<tr>
<th>Img</th>
<th>Title</th>
<th>Department</th>
<th>Description</th>
<th></th>
</tr>
</thead>
<tbody>
<?php
while ($roww = mysqli_fetch_array($resultt)) {
?>
<tr>
<td><img style="width:150px;" src="images/blog/<?php echo $roww["img"]; ?>"></td>
<td>
<?php $dec = $roww['title'];
$removetag = strip_tags($dec);
$trim = $string = substr($removetag,0,600);
echo $trim;?>..</td>
<td><?php echo $roww["blog_department"]; ?></td>
<td>
<?php echo $roww['type'];?>
</td>
<td class="text-right py-0 align-middle">
<div class="btn-group btn-group-sm">
<a href="edit_blog.php?id=<?php echo $roww["id"]; ?>" onclick="return confirm('Are you sure?')" class="btn btn-info"><i class="fas fa-edit"></i></a>
<a href="add-training.php?delete_id=<?php echo $roww["id"]; ?>" onclick="return confirm('Are you sure?')" class="btn btn-danger"><i class="fas fa-trash"></i></a>
</div>
</td>
</tr>
<?php
$serial++;
}
?>
</tbody>
</table>
</div>
<?php
$result_db = mysqli_query($con,"SELECT COUNT(id) FROM blog");
$row_db = mysqli_fetch_row($result_db);
$total_records = $row_db[0];
$total_pages = ceil($total_records / $limit);
/* echo $total_pages; */
$pagLink = "<ul class='pagination'>";
for ($i=1; $i<=$total_pages; $i++) {
$pagLink .= "<li class='page-item'><a class='page-link' href='view-blog.php?page=".$i."'>".$i."</a></li>";
}
echo $pagLink . "</ul>";
?>
</div>
</div>
</section>
<!-- /Main Content -->
</div>
<!-- /Page Content -->
</div>
<!-- Back to Top -->
<a id="back-to-top" href="#" class="back-to-top">
<span class="ti-angle-up"></span>
</a>
<script src="js/jquery-3.2.1.min.js"></script>
<script src="js/popper.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="datatable/jquery.dataTables.min.js"></script>
<script src="datatable/dataTables.bootstrap4.min.js"></script>
<script src="js/custom.js"></script>
<script src="js/custom-datatables.js"></script>
<script src="plugins/jquery/jquery.min.js"></script>
<script src="plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<script src="dist/js/adminlte.min.js"></script>
<script src="plugins/summernote/summernote-bs4.min.js"></script>
<script>
$(function () {
$('.textarea').summernote()
})
</script>
</body>
</html>
|