<?php
session_start();
if(!isset($_SESSION['emailadd'])){
 header("Location: index.php");
}

include 'connect.php';
include("header.php");
include("footer.php");
include("nav.php");



?>


<main>
<head>
	<title>Senarai Cawangan</title>
	<style>
		table {
			border-collapse: collapse;
			width: 100%;
		}
		th, td {
			padding: 8px;
			text-align: left;
			border-bottom: 1px solid #ddd;
		}
		tr:hover {
			background-color: #f5f5f5;
		}
		th {
			background-color: #333;
			color: white;
		}
	</style>
</head>
<body>
	<h2>Senarai Cawangan</h2>
	<table>
		<thead>
			<tr>
				<th>Cawangan</th>
				<th>Alamat</th>
				<th></th>
			</tr>
		</thead>
		<tbody>
			<?php

				// Query database to get clientregno and custname
				$sql = "SELECT branch, add1, add2 FROM branch";
				$result = mysqli_query($conn, $sql);

				// Output data of each row
				while($row = mysqli_fetch_assoc($result)) {
					echo "<tr>";
					echo "<td>" . $row["branch"] . "</td>";
					echo "<td>" . $row["add1"] . "</td>";
					echo "<td>" . $row["add2"] . "</td>";				
					echo "</tr>";
				}

				mysqli_close($conn);
			?>
		</tbody>
	</table>
</body>

<form method="get" action="branch.php">
  <button type="submit" class="add-data-button">Tambah Cawangan</button>
</form>
</main>
