<?php

if(isset($_GET['act'])){
	if($_GET['act']== 'excel'){
		header("Content-Type: application/xls");
		header("Content-Disposition: attachment; filename=Customer.xls");
		header("Pragma: no-cache");
		header("Expires: 0");
	}
}
?>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>Customer DB Export To Excel</title>
		<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
	</head>
	<body>
		<div class="container">
			<div class="row">
				<div class="col-md-5">
					<br /><br /><br />
					<h4>DB EXPORT TO EXCEL</h4>
					<div style="width: 500px;">
					<p>
						<a href="?act=excel" class="btn btn-primary"> Member Export->Excel </a>
						<?php session_start();
							if($_SESSION["Status"] == "ADMIN"){ ?>
								<a href="../home.php" class="btn btn-primary"> Home </a>
							<?php }else{ ?>
								<a href="../homeOther.php" class="btn btn-primary"> Home </a>
							<?php } ?>	
						<a href="../logout.php" class="btn btn-primary"> Logout </a>
					</p>
					</div>
					
					<table border="1" class="table table-hover">
						<thead>
							<tr>
								<th style="text-align: center;">ชื่อ(Login)</th>
                                <th style="text-align: center;">Password</th>
								<th style="text-align: center;">ชื่อ</th>
								<th style="text-align: center;">Status</th>									
							</tr>
						</thead>
						<?php
							include "../functions/dblink.php" ;
							$sql = "SELECT * FROM member" ;
							$result = mysqli_query($con,$sql) ;
							while($row = mysqli_fetch_assoc($result)){ ?>
								<tr>
                                    <td style="text-align: left;"><?php echo $row['Username']; ?></td>
                                    <td style="text-align: left;"><?php echo $row['Password']; ?></td>
									<td style="text-align: left;"><?php echo $row['Name']; ?></td>
									<td style="text-align: left;"><?php echo $row['Status']; ?></td>
								</tr>
						<?php } ?>
					</table>
				</div>
			</div>
		</div>
	</body>
</html>