<?php

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

/* FETCH SARPANCHES */

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

?>

<div class="container">

<h2 class="section-title">Village Sarpanches</h2>

<div class="sarpanch-grid">

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

<?php while($s = mysqli_fetch_assoc($sarpanches)){ ?>

<div class="sarpanch-card">

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

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

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

    <p class="desc">
    <?php echo substr(strip_tags($s['description']),0,120); ?>...
    </p>

</div>

<?php } ?>

<?php } else { ?>

<p>No sarpanches found</p>

<?php } ?>

</div>

</div>

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