<?php

include "../config/db.php";
include "header.php";
include "common.php";

/* FETCH MEMBERS */

$members = mysqli_query($conn,"
SELECT *
FROM village_members
WHERE village_id='$village_id'
ORDER BY id DESC
");

?>

<div class="container">

<h2 class="section-title">Panchayat Members</h2>

<div class="member-grid">

<?php if(mysqli_num_rows($members) > 0){ ?>

<?php while($m = mysqli_fetch_assoc($members)){ ?>

<div class="member-card">

    <?php if(!empty($m['image'])){ ?>
    <img src="/digital_panchayat/uploads/members/<?php echo $m['image']; ?>">
    <?php } ?>

    <h3><?php echo htmlspecialchars($m['name']); ?></h3>

    <?php if(!empty($m['designation'])){ ?>
    <p class="designation"><?php echo htmlspecialchars($m['designation']); ?></p>
    <?php } ?>

    <?php if(!empty($m['mobile'])){ ?>
    <p class="mobile">📞 <?php echo htmlspecialchars($m['mobile']); ?></p>
    <?php } ?>

</div>

<?php } ?>

<?php } else { ?>

<p>No members found</p>

<?php } ?>

</div>

</div>

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