/
var
/
www
/
html
/
stengineers
/
admin
/
Upload FileeE
HOME
<?php header('Access-Control-Allow-Origin: *'); require_once('dbconnection.php'); $nmenu_active = "active"; include 'header.php'; ?> <!-- Begin Page Content --> <div class="container-fluid"> <!-- Page Heading --> <h1 class="h3 mb-2 text-gray-800">News List</h1> <p> <a href="news-add.php" class="btn btn-success btn-icon-split"> <span class="icon text-white-50"> <i class="fas fa-check"></i> </span> <span class="text">Add News & Events</span> </a> </p> <!-- DataTales Example --> <div class="card shadow mb-4"> <div class="card-header py-3"> <!-- <h6 class="m-0 font-weight-bold text-primary">DataTables Example</h6> --> </div> <div class="card-body"> <div class="table-responsive"> <table class="table table-bordered" id="dataTable" width="100%" cellspacing="0"> <thead> <tr> <th>Title</th> <th>Image</th> <th>Event Date</th> <th>News Type</th> <th>Status</th> <th>Action</th> </tr> </thead> <tbody id="table_id"> <?php $s = "select * from news_events"; $res = mysqli_query($con, $s); $num = mysqli_num_rows($res); if ($num == 0) { echo '<tr> <td colspan="6">No Datas Found</td> </tr>'; } else { $sql = "SELECT id,title,id as news_id, thump_image,news_type, status, DATE_FORMAT(event_date, '%d-%m-%Y') as event_date ,'0' FROM news_events ORDER BY id DESC"; $selected = mysqli_query($con, $sql); if (!$selected) { die("Query failed: " . mysqli_error($con)); } $carr = array(); // Initialize $carr as an empty array before the loop. while ($row = mysqli_fetch_assoc($selected)) { $carr[] = $row; } for ($i=0; $i <count($carr) ; $i++) { $id = $carr[$i]['id']; $title = $carr[$i]['title']; $image = $carr[$i]['thump_image']; $news_type = $carr[$i]['news_type']; $news_id = $carr[$i]['news_id']; $created_at = $carr[$i]['event_date']; $status = $carr[$i]['status']; echo "<tr> <td>$title</td> <td><img src='$image' style='width:100px' /></td> <td>$created_at</td> <td>$news_type</td> <td>$status</td> <td style='white-space: nowrap;'> <a href='news-edit.php?id=$id' class='btn btn-info btn-circle btn-sm'> <i class='fas fa-edit'></i> </a> <a class='btn btn-danger btn-circle btn-sm' onclick='deleteData($id)'> <i class='fas fa-trash'></i> </a> </td> </tr>"; } } ?> </tbody> </table> </div> </div> </div> </div> <!-- /.container-fluid --> <script type="text/javascript"> function refreshData() { $("#table_id").load(window.location + " #table_id"); } function deleteData(id) { var id = id; var getData; if(confirm('Are you sure you want to delete?')) { $.ajax({ url: 'api/admin-news.php', type: 'POST', data: { id: id, action: "deletenews", referer: "ezioaws" }, success: function(response) { var data = JSON.parse(response); console.log(data); if (data.status == 'success') { alert("Deleted Successfully") window.location.href = "news_events.php"; } else { alert("Failed, Please try again later") } } }); } } </script> <?php include 'footer.php' ?>