<?php
/***
Auth: Vastvikta Nishad
Date: 08 Feb 2024
Description:Display and Delete Knowledge Base
*/
?>
<div class="style2-table">
    <div class="style-title">
    <h3>FAQ</h3>
        <div class="row">
        <?php $new_base = base64_encode('new_base');?>
            <div class="col-sm-1" style="text-align: end;">
            <a href="admin_index.php?token=<?php echo $new_base;?>" class="button-orange1">New FAQ</a>
                </div>
         </div>  
    <div id="success"></div>
    <form name="frmService" action="" method="post">
        <div class="table" id="SRallview">
            <div class="">
                <div class="div2">
                    <table class="tableview tableview-2" id="admin_table">
                        <thead>
                            <tr class="background">
                                <td align="center" width="5%">S.No.</td>
                                <td align="left" width="35%">Question</td>
                                <td align="center">Answer</td>
                                <td align="center" width="5%">Action</td>
                            </tr>
                        </thead>
                        <tbody>
                            <?php
                            $result = getBaseData();

                            if (mysqli_num_rows($result) == 0) {
                                echo '<tr><td colspan="4" align="center" class="contentred">No records found!</td></tr>';
                            } else {
                                $count = 1;
                                while ($row_doc = mysqli_fetch_array($result)) {
                                    $new_base = base64_encode('new_base');
                                    $id = base64_encode($row_doc['i_id']);
                                    ?>
                                    <tr>
                                        <td align="center"><?php echo $count; ?></td>
                                        <td align="left"><?php echo $row_doc['v_qus']; ?></td>
                                        <td align="left"><?php echo $row_doc['v_ans']; ?></td>
                                        <td>
                                            <a href='javascript:void(0)' onclick="window.location.href='admin_index.php?token=<?php echo $new_base ;?>&id=<?= $id ?>';">
                                                <img src="<?=$SiteURL?>public/images/edit-icon.png" border="0" alt="Edit" />
                                            </a>
                                            <a href='javascript:void(0);' data-i_id="<?php echo $row_doc['i_id'] ?>" class="base_delete">
                                                <img src="<?=$SiteURL?>public/images/delete-icon.png" border="0"  alt="delete">
                                            </a>
                                        </td>
                                    </tr>
                                    <?php
                                    $count++;
                                }
                            }
                            ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </form>
</div>
