<?php include('site-header.php'); ?>
<!-- end of LOGO CONTAINER -->
<!-- - - - - - - - - - - - - -->
<!-- start of SIDEBAR -->
<!-- - - - - - - - - - - - - -->
<?php include('left-nevigation.php'); ?>
<!-- - - - - - - - - - - - - -->
<!-- end of SIDEBAR -->
<!-- - - - - - - - - - - - - -->
<main id="playground">
<!-- - - - - - - - - - - - - -->
<!-- start of TOP NAVIGATION -->
<!-- - - - - - - - - - - - - -->
<?php include('site-top-header.php'); ?>
<?php
$id = mysqli_real_escape_string($link,$_GET['del']);
$sel = mysqli_query($link,"select * from tbl_category where cat_id=$id");
$arr = mysqli_fetch_assoc($sel);
if(isset($_GET['del']))
{
$image = $arr['category_image'];
$id = $_GET['del'];
if(mysqli_query($link,"DELETE FROM `tbl_category` WHERE cat_id=$id"))
{
$prosel = mysqli_query($link,"select * from tbl_product where pro_category=$id");
while($pro_arr = mysqli_fetch_assoc($prosel))
{
$delimage = $pro_arr['pro_image'];
if(mysqli_query($link,"delete from tbl_product where pro_category=$id"))
{
unlink("../product-image/$delimage");
}
}
unlink("../uploaded/$image");
echo "<script>window.location.href='update-category.php';</script>";
}
}
?>
<!-- -->
<?php
extract($_POST);
if(isset($Add))
{
$hid = $_POST['hid'];
$cour = mysqli_query($link,"select * from tbl_category where home_status='Home'");
if(mysqli_query($link,"update tbl_category set home_status='$Add' where cat_id='$hid'"))
{
$msg= "<p style='color:green;'>Category Add Home Page!!!!</p>";
}
}
if(isset($Remove))
{
$hid = $_POST['hid'];
if(mysqli_query($link,"update tbl_category set home_status='$Remove' where cat_id='$hid'"))
{
$msg= "<p style='color:green;'>Category Remove!!!!</p>";
}
}
?>
<section id="page-title" class="row">
<div class="col-md-8">
<h1>Category</h1>
<p class="lead">Update your product category below</strong>.</p>
</div>
<div class="col-md-4">
</div>
</section>
<!-- / PAGE TITLE -->
<div class="container-fluid">
<div><?=@$msg;?></div>
<div class="row">
<div class="col-md-4">
<section class="panel tasks-widget"></section>
</div>
<div class="col-md-4">
<div class="panel-body"> <form method="post">
<div class="form-group text-center"><a href="add-edit-category.php" class="btn btn-primary">Add New Category</a></button> </div>
</form>
</div>
</div>
<div class="col-md-4">
<section class="panel tasks-widget"></section>
</div>
</div>
<!-- / row -->
<div class="row">
<div class="col-md-12">
<section class="panel panel-primary">
<header class="panel-heading">
<h3 class="panel-title">Existing Categories</h3>
</header>
<table class="table table-hover table-responsive" width="100%">
<tbody>
<tr>
<th scope="row" style="color:black;">S. No</th>
<th style="color:black;">Category Name</th>
<!-- <th style="color:black;"> Image</th> -->
<th style="color:black;">Add Image</th>
<!-- <th style="color:black;">Home Product</th> -->
<th style="color:black;">Action</th>
</tr>
<?php
$sn=0;
$sel = mysqli_query($link,"select * from tbl_category");
while($arr = mysqli_fetch_assoc($sel))
{
$sn++;
?>
<tr>
<td><?=$sn?></td>
<td><?=$arr['cate_name']?></td>
<td><a href="Category-image.php?pro_id=<?=$arr['cat_id'];?>" class="btn btn-success">Add Image</a></td>
-->
<!-- <td><img src="../category-image/<?=$arr['category_image'];?>" alt="<?=$arr['category_image'];?>" height="100px" width="100px"></td> -->
<!-- <td>
<?php
if($arr['home_status']=="Home")
{
?>
<form method="post">
<input type="hidden" name="hid" value="<?=$arr['cat_id'];?>">
<input type="submit" name="Remove" value="Remove" class="btn btn-danger">
</form>
<?php
}
else
{
?>
<form method="post">
<input type="hidden" name="hid" value="<?=$arr['cat_id'];?>">
<input type="submit" name="Add" value="Home" class="btn btn-success">
</form>
<?php
}
?>
</td> -->
<td><a class="btn btn-success" href="edit-category.php?edit=<?=$arr['cat_id'];?>">Edit</a> <a class="btn btn-danger" href="?del=<?=$arr['cat_id'];?>">Delete</a></td>
</tr>
<?php
}
?>
</tbody>
</table>
</section>
</div>
</div>
</div>
<!-- / container-fluid -->
<?php include('site-footer.php'); ?>