Viewing file: articles.php (8.11 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php include('include/header.php'); include('include/conn.php'); error_reporting(E_ALL); ini_set('display_errors', 1); $admin_type = $_SESSION['admin_type']; $adminID = $_SESSION['admin_id']; $adminType = $_SESSION['admin_type']; ?>
<link href="https://cdn.datatables.net/1.12.1/css/jquery.dataTables.min.css" rel="stylesheet" type="text/css"> <link href="https://cdn.datatables.net/buttons/2.2.3/css/buttons.dataTables.min.css" rel="stylesheet" type="text/css">
<style type="text/css"> .dt-buttons { width: 50%; } </style>
<!-- begin MAIN PAGE CONTENT --> <div id="page-wrapper" style="min-height:142vh;"> <div class="page-content"> <!-- begin PAGE TITLE ROW --> <div class="row"> <div class="col-lg-12"> <div class="page-title"> <h1>Articles</h1> </div> <?php // if ($admin_type !== 'Admin') { ?> <div class="row"> <div class="col-md-2"> <a href="add_articles.php" class="btn btn-success">Article +</a> </div> </div> <?php // } ?> <br> </div>
<table id="data_table" class="display dataTable table table-striped table-bordered table-hover table-green profile-table"> <thead> <tr> <th scope="col">S.No</th> <th scope="col">Title</th> <th scope="col">Sub Title</th> <th scope="col">Author</th> <th scope="col">Article</th> <th scope="col">Approval Status</th> <th scope="col">Action</th> <th scope="col">View</th> </tr> </thead> <tbody> <?php if ($adminType === 'Author') {
$sql_desig = "SELECT * FROM `articles` WHERE art_create_by=$adminID ORDER BY art_id DESC"; } else { $sql_desig = "SELECT * FROM `articles` ORDER BY art_id DESC"; } // $sql_desig = "SELECT * FROM `articles` WHERE b.art_create_by=$adminID ORDER BY art_id DESC"; $desig_result = mysqli_query($conn, $sql_desig); if ($desig_result) { $i = 1; // Initialize the counter outside the loop while ($row = mysqli_fetch_assoc($desig_result)) { $art_id = $row['art_id']; ?> <tr> <td><?= $i ?></td> <td><?= $row['art_title'] ?></td> <td><?= $row['art_sub_title'] ?></td> <td><?= $row['art_author'] ?></td> <td><img src="<?= $row['art_image'] ?>" alt="" style="width: 100px;"></td> <td> <?php if ($row['art_status'] == 0) { if ($admin_type == 'Admin' || $admin_type == 'Super Admin') {
?> <a href="change_status.php?art_id=<?= $art_id ?>&&status=1" class="btn btn-warning"> Draft </a> <?php } else { ?> <button class="btn btn-warning"> Draft</button> <?php } } else { ?> <a href="" class="btn btn-primary"> Approved </a> <?php if ($admin_type == 'Admin' || $admin_type == 'Super Admin') { ?> <a href="change_status.php?art_id=<?= $art_id ?>&&status=0" class="btn btn-danger"> Revert </a> <?php } } ?> </td> <td> <?php if ($row['art_status'] == 1 && $adminType === 'Author') { ?> <?php }else{ ?> <a href="edit_articles.php?art_edit=<?= $art_id ?>" class="btn btn-primary"> <i class="fa fa-edit text-white"></i> </a> <a href="article_del.php?art_del=<?= $art_id ?>" class="btn btn-warning"> <i class="fa fa-trash text-white"></i> </a> <?php } ?> </td> <td><a href="view_articles.php?art_id=<?= $art_id ?>" class="btn btn-primary">view</a></td> </tr> <?php $i++; // Increment the counter inside the loop } } ?> </tbody> </table> </div> <!-- /.col-lg-12 --> </div> <!-- /.row --> </div> <!-- /.page-content --> </div> <!-- /#page-wrapper -->
<!-- begin FOOTER --> <?php include('include/footer.php'); ?> <!-- end FOOTER --> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <script src="https://cdn.datatables.net/1.12.1/js/jquery.dataTables.min.js"></script> <script src="https://cdn.datatables.net/buttons/2.2.3/js/dataTables.buttons.min.js"></script> <script src="https://cdn.datatables.net/buttons/2.2.3/js/buttons.html5.min.js"></script> <script src="https://cdn.datatables.net/buttons/2.2.3/js/buttons.print.min.js"></script> <script src="https://cdn.datatables.net/buttons/2.2.3/js/buttons.colVis.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js"></script>
<script> $(document).ready(function() { var table = $('#data_table').DataTable({ dom: 'Bfrtip', buttons: [{ extend: 'copy', className: 'btn btn-primary', text: 'Copy' }, { extend: 'csv', className: 'btn btn-primary', text: 'CSV' }, { extend: 'excel', className: 'btn btn-primary', text: 'Excel' }, { extend: 'pdf', className: 'btn btn-primary', text: 'PDF' }, { extend: 'print', className: 'btn btn-primary', text: 'Print' } ] });
}); </script>
|