D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
thread-self
/
root
/
home
/
markniuj
/
bazmeasar.com
/
admin
/
Filename :
allevents.php
back
Copy
<?php include "../config.php"; ?> <!DOCTYPE html> <html> <head> <title>Event Management</title> <!-- responsive meta --> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- For IE --> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <!-- Module css --> <style> table { border-collapse: collapse; width: 100%; } table, th, td { border: 1px solid #ddd; } th, td { padding: 10px; text-align: left; } th { background-color: #f2f2f2; } .edit-icon, .delete-icon { color: blue; cursor: pointer; } </style> </head> <body> <h1>Event Management</h1> <a href="index.php">Add New Event</a> <button style="float:right;"><a href="displayevents.php">share comming even</a></button> <table> <tr> <th>Event Name</th> <th>Event Name (Urdu)</th> <th>Event Date</th> <th>Event Time</th> <th>Actions</th> </tr> <?php // Get event details from the database // Fetch events from the database, order by the latest event $sql = "SELECT * FROM events ORDER BY id DESC"; $result = $conn->query($sql); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { echo "<tr>"; echo "<td><a href='view_event.php?id={$row['id']}'>{$row['event_name']}</a></td>"; echo "<td>{$row['event_nameurdu']}</td>"; echo "<td>{$row['event_date']}</td>"; echo "<td>{$row['event_time']}</td>"; echo "<td> <span class='delete-icon' data-id='{$row['id']}'>Delete</span> </td>"; echo "</tr>"; } } else { echo "<tr><td colspan='5'>No events found.</td></tr>"; } // Close the database connection $conn->close(); ?> </table> <script> // JavaScript code to handle edit and delete actions const editIcons = document.querySelectorAll('.edit-icon'); const deleteIcons = document.querySelectorAll('.delete-icon'); editIcons.forEach(icon => { icon.addEventListener('click', (event) => { const eventId = event.target.getAttribute('data-id'); // Redirect to the edit page with the event ID window.location.href = `edit_event.php?id=${eventId}`; }); }); deleteIcons.forEach(icon => { icon.addEventListener('click', (event) => { const eventId = event.target.getAttribute('data-id'); if (confirm("Are you sure you want to delete this event?")) { // Redirect to the delete page with the event ID window.location.href = `delete_event.php?id=${eventId}`; } }); }); </script> </body> </html>