/
var
/
www
/
html
/
stengineers
/
admin
/
Upload FileeE
HOME
<?php session_start(); if (!isset($_SESSION['login_user'])) { header("Location: login.php"); exit(); } header('Access-Control-Allow-Origin: *'); require_once 'dbconnection.php'; $pmenu_active = "active"; include 'header.php'; ?> <!-- Begin Page Content --> <div class="container-fluid"> <div class="flx-cls"> <!-- Page Heading --> <div > <h1 class="h3 mb-2 text-gray-800">Product List</h1> </div> <div class="d-flex align-items-center"> <p><a href="brands.php" class="btn bg-cream btn-icon-split"> <span class="text pa-20">Add Brand</span> </a></p> <p><a href="category-list.php" class="btn bg-cream btn-icon-split"> <span class="text pa-20">Add Category</span> </a></p> <p><a href="product-add.php" class="btn bg-green btn-icon-split"> <span class="text pa-20">Add New Product</span> </a></p> </div> </div> <!-- 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>Product Name</th> <th>Product Image</th> <th>Category / Subcategory</th> <th>Status</th> <th>Action</th> </tr> </thead> <!-- <tfoot> <tr> <th>Title</th> <th>Image</th> <th>Created at</th> <th>Total Comments</th> <th>Status</th> <th>Approved</th> <th>Action</th> </tr> </tfoot> --> <tbody id="table_id"> <?php $s = "select * from products"; $res = mysqli_query($con, $s); $num = mysqli_num_rows($res); if ($num == 0) { echo '<tr> <td colspan="6">No Datas Found</td> </tr>'; } else { $productQuery = $con->query("SELECT * FROM products order by product_id desc"); while ($productRow = $productQuery->fetch_assoc()) { $id = $productRow['product_id']; $product_title = $productRow['product_title']; $preview_image = $productRow['preview_image']; $category = $productRow['category']; $sub_category = $productRow['sub_category']; $status = $productRow['status']; $row1_c = mysqli_query($con, "select * from category as a where a.id='$category'"); $row2_c = mysqli_fetch_array($row1_c); $mcategory_name = $row2_c['category_name']; $murl = $row2_c['url']; $row1_sub = mysqli_query($con, "select * from category as a where a.id='$sub_category'"); $row2_sub = mysqli_fetch_array($row1_sub); $scategory_name = $row2_sub['category_name']; $surl = $row2_sub['url']; echo "<tr> <td> $product_title</td> <td><img src='$preview_image' style='width:100px' /></td> <td><b>Category:</b> $mcategory_name <br> <b>Sub Category:</b> $scategory_name</td> <td>$status</td> <td style='white-space: nowrap;'> <a href='product-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-product.php', type: 'POST', data:{id:id,action:"deleteproduct", referer:"ezioaws"}, success: function (response) { var data = JSON.parse(response); console.log(data); if (data.status == 'success') { alert("Deleted Successfully") window.location.href="products.php"; } else { alert("Failed, Please try again later") } } }); } } </script> <?php include 'footer.php'?>