<?php

include "../../config/master.php";
allowRoles([1]);

include "../layout/header.php";
include "../layout/sidebar.php";

$blocks = mysqli_query($conn,"
SELECT b.*, d.district_name
FROM blocks b
LEFT JOIN districts d ON b.district_id=d.id
");

?>

<div class="main">

<h2>Block List</h2>

<a href="add_block.php" class="btn-success">Add Block</a>

<table>

<tr>
<th>ID</th>
<th>District</th>
<th>Block</th>
</tr>

<?php while($row=mysqli_fetch_assoc($blocks)){ ?>

<tr>

<td><?php echo $row['id']; ?></td>
<td><?php echo $row['district_name']; ?></td>
<td><?php echo $row['block_name']; ?></td>

</tr>

<?php } ?>

</table>

</div>

<?php include "../layout/footer.php"; ?>