<?php
include('include/main.inc.php');
// $sel_faq_query = "Select * from faq_tbl order by slno asc";
// $res_faq = $dbconn->query($sel_faq_query);
// if($res_faq->num_rows > 0){
//     $sno = 0;
    
?>
<div class="faq_section">
    <div class="container">
        <?php
        $sno = 1;
        $sel_faq_query = mysqli_query($dbconn, "SELECT * FROM faq_tbl WHERE category_id='$category_id' ORDER BY slno ASC");

        if (mysqli_num_rows($sel_faq_query) > 0) {
        ?>
            <div class="title_2">FAQs</div>
            <div class="clearfix"></div>

            <div class="accordion" id="accordionExample">
                <?php while ($res_faq = mysqli_fetch_array($sel_faq_query)) { ?>
                    <div class="accordion-item wow fadeInLeft" data-wow-delay=".<?= $sno; ?>s">
                        <h5 class="accordion-header" id="heading_<?= $sno; ?>">
                            <span class="accordion-button" role="button" data-bs-toggle="collapse" data-bs-target="#faq_<?= $sno; ?>" aria-expanded="<?= ($sno == 1) ? 'true' : 'false'; ?>" aria-controls="heading_<?= $sno; ?>">
                                <?= $res_faq['question']; ?>
                            </span>
                        </h5>
                        <div id="faq_<?= $sno; ?>" class="accordion-collapse collapse <?= ($sno == 1) ? 'show' : ''; ?>" aria-labelledby="heading_<?= $sno; ?>" data-bs-parent="#accordionExample">
                            <div class="accordion-body">
                                <p><?= $res_faq['answer']; ?></p>
                            </div>
                        </div>
                    </div>
                    <?php $sno++;
                } ?>
            </div>
        <?php
        }
        ?>
    </div>
</div>
