<?php 
include("connection/conn.php");
if($_SESSION['adminuser']==''){
		header("location:index.php");
		exit();
	}

// Pagination variables
$adjacents = 3;
$limit = 20; // Items per page
$page = isset($_GET['page']) ? (int)$_GET['page'] : 1;
if ($page <= 0) $page = 1; // Ensure page is at least 1

$start = ($page - 1) * $limit; 

// Fetch total number of records
$total_pages_query = "SELECT COUNT(*) AS total FROM course_category";
$total_pages_result = mysqli_query($link, $total_pages_query);
$total_pages_data = mysqli_fetch_assoc($total_pages_result);
$total_pages = (int)$total_pages_data['total'];

// Fetch paginated records, oldest data first
$sql = "SELECT * FROM course_category ORDER BY id ASC LIMIT $start, $limit";
$result = mysqli_query($link, $sql);
$count = mysqli_num_rows($result);

// Pagination calculation
$lastpage = ceil($total_pages / $limit);
$prev = $page - 1;
$next = $page + 1;
$lpm1 = $lastpage - 1;

// Ensure variables like $dat, $dat1, and $centername are handled properly if required
$path = "dat=$dat&dat1=$dat1&centername=$centername";
$targetpage = "manage-contact.php";

// Export data as CSV functionality (if required)
// Place the relevant export logic here

?>

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>Administrator | Manage Services Category</title>
		<link href="css/bootstrap.css" rel="stylesheet" />
		<link href="css/style.css" rel="stylesheet" />
		<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
		<link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css' />
	</head>
	
	<body>
		<div id="wrapper">
			<?php
				include("top-header.php");
				include("right-sec.php");
			?>
			<div id="page-wrapper" >
				<div id="page-inner">
					<div class="row">
						<div class="col-md-12">
							<h3 class="page-header">
								Manage Class Category<small></small>
							</h3>
							
							<div class="table-sec">
								<table>
								
									<tr>
										<th>Id</th>
										<th>Category</th>
										
										<th>Status</a></th>
									</tr>
									<?php
									  $i=1;
									  while($find=mysqli_fetch_array($result)){
										$color = (($i%2) == 0)?"#e7f3ff":"#FFFFFF";
										
								?>
									<tr>
										<td><?php echo $i;?></td>
										
										<td><?php echo $find['course'];?></td>
										<td><?php echo $find['fee'];?></td>
																				<td>
											<ul class="table-ul">
												
												
												
												<li><a href="delete-Category.php?id=<?php echo $find['id'];?>" onclick="return confirm('are you sure delete this?');"><i class="delete fa fa-trash"></i></a></li>
											</ul>
										</td>
									</tr>
									  <?php $i++; } ?>
									
								</table>
							</div>
						</div>
					</div> 
				</div>
			</div>
			<footer class="footer-sec">
				<div class="container">
					<div class="row">
						<div class="col-md-12">
							<p class="text-center">All right reserved. Template Design by: <a href="">drmakeoversalon</a></p>
						</div>
					</div>
				</div>
			</footer>
		</div>
		
		
		<!-- jQuery Js -->
		<script src="js/jquery-1.10.2.js"></script>
		<script src="js/bootstrap.min.js"></script>
		<script src="js/jquery.metisMenu.js"></script>
		<script src="js/custom-scripts.js"></script>
	</body>
</html>
