D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home3
/
encodto1
/
public_html
/
encoadminders
/
Filename :
showcase.php
back
Copy
<?php session_start(); include 'config.php'; if (!isset($_SESSION['admin_name'])) { echo '<script>window.location.href = "login.php";</script>'; exit; } // Handle the delete action if (isset($_GET['delete_id'])) { $delete_id = $_GET['delete_id']; // Delete the showcase image from the database $delete_query = "DELETE FROM showcase WHERE showcase_id = ?"; $stmt = mysqli_prepare($conn, $delete_query); mysqli_stmt_bind_param($stmt, 'i', $delete_id); if (mysqli_stmt_execute($stmt)) { // Optionally, delete the image from the server as well (if required) // Assuming images are stored in the "uploads/showcase/" folder $image_query = "SELECT image FROM showcase WHERE showcase_id = ?"; $image_stmt = mysqli_prepare($conn, $image_query); mysqli_stmt_bind_param($image_stmt, 'i', $delete_id); mysqli_stmt_execute($image_stmt); $image_result = mysqli_stmt_get_result($image_stmt); $image_row = mysqli_fetch_assoc($image_result); $image_path = 'uploads/showcase/' . $image_row['image']; if (file_exists($image_path)) { unlink($image_path); // Delete the image file } echo '<script>alert("Showcase item deleted successfully!"); window.location.href = "showcase.php";</script>'; } else { echo '<script>alert("Error deleting showcase item."); window.location.href = "showcase.php";</script>'; } // Close the prepared statement mysqli_stmt_close($stmt); mysqli_stmt_close($image_stmt); } // Fetch showcase images from the database $query = "SELECT * FROM showcase ORDER BY showcase_id DESC"; $result = mysqli_query($conn, $query); ?> <!DOCTYPE html> <html lang="en"> <head> <?php require('style.php'); ?> <title>Showcase</title> <style> :root { --primary-color: #007bff; --secondary-color: #333; --accent-color: #28a745; --danger-color: #dc3545; --background-color: #f9f9f9; --card-border: #ddd; --font-family: 'Poppins', sans-serif; } body { font-family: var(--font-family); background-color: #fff; margin: 0; padding: 0; color: var(--secondary-color); } .home-section { padding-top: 40px; } .gallery-container { max-width: 1200px; margin: 0 auto; background: #fff; padding: 20px; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1); border-radius: 10px; } .gallery-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; border-bottom: 2px solid var(--primary-color); padding-bottom: 10px; } .gallery-header h1 { font-size: 28px; color: var(--primary-color); font-weight: bold; } .gallery-header .btn-add { padding: 9px 20px; background-color: var(--primary-color); color: #fff; text-decoration: none; border-radius: 5px; font-size: 10px; transition: background 0.3s ease; } .gallery-header .btn-add:hover { background-color: #0056b3; } .gallery-list { display: flex; flex-direction: column; gap: 30px; } .gallery-item { display: flex; flex-wrap: wrap; gap: 20px; border: 1px solid var(--card-border); border-radius: 10px; padding: 20px; background-color: var(--background-color); box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); transition: transform 0.3s ease, box-shadow 0.3s ease; } .gallery-item:hover { transform: translateY(-5px); box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15); } .gallery-image-col { flex: 0 0 33.33%; /* col-4 equivalent */ display: flex; justify-content: center; align-items: center; background: #fff; padding: 10px; border-radius: 10px; } .gallery-image { max-width: 100%; height: auto; border-radius: 8px; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2); } .gallery-info-col { flex: 0 0 50%; /* col-6 equivalent */ display: flex; flex-direction: column; gap: 15px; padding: 10px; } .field{ display: flex; flex-wrap: wrap; gap: 20px; border: 1px solid var(--card-border); border-radius: 10px; padding: 20px; background-color: var(--background-color); box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); transition: transform 0.3s ease, box-shadow 0.3s ease; } .field h4 { font-size: 16px; color: var(--primary-color); margin-bottom: 5px; } .field p { font-size: 14px; color: var(--secondary-color); word-wrap: break-word; margin: 0; } .action-buttons { display: flex; gap: 15px; margin-top: 10px; } .btn-edit, .btn-delete { padding: 8px 15px; font-size: 14px; color: #fff; text-decoration: none; border-radius: 5px; transition: background 0.3s ease; } .btn-edit { background-color: var(--accent-color); } .btn-edit:hover { background-color: #218838; } .btn-delete { background-color: var(--danger-color); } .btn-delete:hover { background-color: #c82333; } @media (max-width: 768px) { .gallery-item { flex-direction: column; } .gallery-image-col, .gallery-info-col { flex: 1 1 100%; } } .btn-edit, .btn-delete { display: block; /* Ensure the button takes up the full width */ width: 100%; /* Full width of the parent container */ padding: 10px 15px; /* Adjust padding for better spacing */ font-size: 14px; color: #fff; text-decoration: none; border-radius: 5px; text-align: center; /* Center align the text */ transition: background 0.3s ease, transform 0.2s ease; margin-bottom: 10px; /* Add spacing between buttons */ } /* Add hover effects */ .btn-edit:hover { background-color: #218838; /* Darker green for hover */ transform: scale(1.05); } .btn-delete:hover { background-color: #c82333; /* Darker red for hover */ transform: scale(1.05); } /* Responsive adjustments */ @media (max-width: 768px) { .btn-edit, .btn-delete { font-size: 12px; /* Smaller font size for mobile */ padding: 8px 12px; /* Adjust padding for smaller screens */ } } </style> </head> <body> <?php include('sidebar.php') ?> <div class="home-section"> <div class="gallery-container"> <div class="gallery-header"> <h1>Showcase</h1> <a href="add_showcase.php" class="btn-add">Add Showcase</a> </div> <div class="gallery-list"> <?php while ($row = mysqli_fetch_assoc($result)) : ?> <div class="gallery-item"> <div class="gallery-image-col"> <img src="uploads/showcase/<?php echo htmlspecialchars($row['image']); ?>" alt="Showcase Image" class="gallery-image"> </div> <div class="gallery-info-col"> <div class="field"> <h4>ID:</h4> <p><?php echo htmlspecialchars($row['showcase_id']); ?></p> </div> <div class="field"> <h4>Title:</h4> <p><?php echo htmlspecialchars($row['title']); ?></p> </div> <div class="field"> <h4>Link:</h4> <p><?php echo htmlspecialchars($row['link']); ?></p> </div> <div class="action-buttons"> <a href="edit_showcase.php?id=<?php echo $row['showcase_id']; ?>" class="btn-edit">Edit</a> <a href="?delete_id=<?php echo $row['showcase_id']; ?>" class="btn-delete" onclick="return confirm('Are you sure you want to delete this item?');">Delete</a> </div> </div> </div> <?php endwhile; ?> </div> </div> <?php include('footer.php') ?> </div> </body> </html>