<?php
session_start();
ini_set('display_errors', 1);
require('../includes/cmain.inc.php');
if($_SESSION['logged_in'] != true) {
header("Location: index.php");
    exit();	
	  }
	  
	  if($_REQUEST['action']=='delete'){
		  $sql3 = "delete from `tbl_blogcatp` where id=".$id;
		  if ($conn->query($sql3) === TRUE) {
          echo "Record deleted successfully";
          } else {
          echo "Error deleting record: " . $conn->error;
          }
		  
	  }
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Welcome Admin</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {
  box-sizing: border-box;
}

body {
  font-family: Arial, Helvetica, sans-serif;
}

/* Style the header */
header {
  background-color: #888888;
  padding: 30px;
  text-align: center;
  font-size: 20px;
  color: white;
}

/* Create two columns/boxes that floats next to each other */
nav {
  float: left;
  width: 20%;
  height: 500px; /* only for demonstration, should be removed */
  background: #DCDCDC;
  padding: 20px;
}

/* Style the list inside the menu */
nav ul {
  list-style-type: none;
  padding: 0;
}

article {
  float: left;
  padding: 20px;
  width: 80%;
  background-color: #f1f1f1;
  font-size:10px;
  height: 500px; /* only for demonstration, should be removed */
}

/* Clear floats after the columns */
section::after {
  content: "";
  display: table;
  clear: both;
}

/* Style the footer */
footer {
  background-color: #777;
  padding: 10px;
  text-align: center;
  color: white;
}
table, th, td {
  border: 1px solid black;
  border-collapse: collapse;
}

/* Responsive layout - makes the two columns/boxes stack on top of each other instead of next to each other, on small screens */
@media (max-width: 600px) {
  nav, article {
    width: 100%;
    height: auto;
  }
}
</style>
</head>
<body>

<header>
  <h2>Welcome Admin</h2>
</header>

<section>
  <nav>
    <ul>
     <li><a href="welcome.php">Home</a></li>
      <li><a href="service_list.php">Service List</a></li>
      <li><a href="logout.php">Logout</a></li>
    </ul>
  </nav>
  
  

  <article>
  <h3><a href="add_blogcat.php" align="left">Add New Blog Category</a></h3>
    <h1>Blog Categories List</h1><h3>  
    <table>
	<tr>
	<th>S. No.</th>
	<th>Provided Category</th>
	<th>Edit</th>
	<th>Delete</th>
	
	</tr>
	<?php
	$count=0;
	$listQuery="SELECT * FROM tbl_blogcatp";
	$result=mysqli_query($conn,$listQuery);
	while($row=mysqli_fetch_array($result)){
	?>
	<tr>
	<td><?php echo $row['id'];?></td>
	<td><?php echo $row['catP_Name'];?></td>
	<td><a href="add_blogcat.php?id=<?php echo $row['id'];?>&action=edit" >Edit</a></td>
	<td><a href="blog_cat.php?id=<?php echo $row['id'];?>&action=delete" onclick="return stdel_confirm();" >Delete</a></td>
	</tr>
	<?php 
	$count++;
	}?>
	</table>
	<script>
function stdel_confirm(){  return confirm("Are you sure want to delete?"); }
</script>

<div style="text-align:right"><a href="service_list.php" align="right">Back to Service List</a></div>
  </article>
</section>


<footer>
  <p></p>
</footer>

</body>
</html>

