View file Remove image backgrounds/remove-bg/dark/admin-pannel/webpagelist-deta.php

File size: 5.16Kb
<div class="col-md-12">
   <div class="card border-0  mt-4 p-0 shadow mb-4">
      <div class="card-header bg-white border-bottom py-3 border-top-left-right">
         <h6 class="m-0 fw-bold">Edit Meta title, Meta Description, Meta Title</h6>
      </div>
      <div class="card-body">
      <?php
require_once('config/core.php');

// Pagination settings
$records_per_page = 10;
$page = isset($_GET['page']) && is_numeric($_GET['page']) ? $_GET['page'] : 1;
$offset = ($page - 1) * $records_per_page;

// Database connection
$conn = mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);

// Check if connection is successful
if (!$conn) {
    die("Error: Unable to connect to the database.");
}

// Query to fetch data with pagination
$sql = "SELECT * FROM webpages LIMIT $offset, $records_per_page";
$result = mysqli_query($conn, $sql);

// Check if query execution is successful
if (!$result) {
    die("Error executing the query: " . mysqli_error($conn));
}
?>

<!-- Table to display webpages -->
<table class="table table-bordered">
    <thead>
        <tr>
            <th>Title</th>
            <th>Meta Description</th>
            <th>Meta Keyword</th>
            <th>Page Name</th>
            <th>Action</th>
        </tr>
    </thead>
    <tbody>
        <!-- Loop through fetched data and display rows -->
        <?php while ($row = mysqli_fetch_assoc($result)) : ?>
            <tr>
                <td><?php echo $row["title"]; ?></td>
                <td><?php echo $row["meta_description"]; ?></td>
                <td><?php echo $row["meta_keyword"]; ?></td>
                <td><?php echo $row["webpage_name"]; ?></td>
                <td>
                    <button class="btn btn-primary edit-webpagebutton" data-bs-toggle="modal" data-bs-target="#editwebpage" data-title="<?php echo $row["title"]; ?>" data-meta-description="<?php echo $row["meta_description"]; ?>" data-meta-keyword="<?php echo $row["meta_keyword"]; ?>" data-id="<?php echo $row["id"]; ?>">Edit</button>
                </td>
            </tr>
        <?php endwhile; ?>
    </tbody>
</table>

<!-- Pagination -->
<nav aria-label="Page navigation">
    <ul class="pagination">
        <!-- Previous page link -->
        <?php if ($page > 1) : ?>
            <li class="page-item">
                <a class="page-link" href="?page=<?php echo ($page - 1); ?>" aria-label="Previous">
                    <span aria-hidden="true">Previous</span>
                </a>
            </li>
        <?php endif; ?>

        <!-- Page numbers -->
        <?php
        $total_rows_sql = "SELECT COUNT(*) AS total FROM webpages";
        $total_rows_result = mysqli_query($conn, $total_rows_sql);
        $total_rows = mysqli_fetch_assoc($total_rows_result)['total'];
        $total_pages = ceil($total_rows / $records_per_page);

        for ($i = 1; $i <= $total_pages; $i++) :
            ?>
            <li class="page-item <?php echo ($page == $i) ? 'active' : ''; ?>">
                <a class="page-link" href="?page=<?php echo $i; ?>"><?php echo $i; ?></a>
            </li>
        <?php endfor; ?>

        <!-- Next page link -->
        <?php if ($page < $total_pages) : ?>
            <li class="page-item">
                <a class="page-link" href="?page=<?php echo ($page + 1); ?>" aria-label="Next">
                    <span aria-hidden="true">Next</span>
                </a>
            </li>
        <?php endif; ?>
    </ul>
</nav>


<?php
// Close database connection
mysqli_close($conn);
?>

      </div>
   </div>
</div>
<!-- Edit Modal -->
<div class="modal fade" id="editwebpage" tabindex="-1" aria-labelledby="editwebpageLabel" aria-hidden="true">
   <div class="modal-dialog">
      <div class="modal-content">
         <div class="modal-header">
            <h5 class="modal-title" id="editwebpageLabel">Edit Webpage</h5>
            <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
         </div>
         <div class="modal-body">
            <form id="editForm">
               <div class="mb-3">
                  <label class="form-label" for="edit_title">Title</label>
                  <input type="text" class="form-control" id="edit_title" name="edit_title">
               </div>
               <div class="mb-3">
                  <label class="form-label" for="edit_meta_description">Meta Description</label>
                  <input type="text" class="form-control" id="edit_meta_description" name="edit_meta_description">
               </div>
               <div class="mb-3">
                  <label class="form-label" for="edit_meta_keyword">Meta Keyword</label>
                  <input type="text" class="form-control" id="edit_meta_keyword" name="edit_meta_keyword">
               </div>
               <input type="hidden" id="edit_id" name="edit_id">
            </form>
         </div>
         <div class="modal-footer">
            <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
            <button type="button" class="btn btn-primary" id="saveChangesButton">Save changes</button>
         </div>
      </div>
   </div>
</div>