How to develop Projects(EMS) Using PHP and Mysql Part 11

Rashmi Mishra
0

 

How to develop Projects(EMS) Using PHP and Mysql 

Part 11


Module 3: Admin Panel – Manage Events and Bookings

🎯 Purpose:

Allow admin users to manage events and view booking details.

💡 Functionalities:

  • Edit existing events
  • Delete events
  • View all bookings for each event
  • Cancel or confirm bookings (optional)
  • View booking statistics

📁 Suggested Files:

/admin/

── dashboard.php              # Admin dashboard

── edit_event.php            # Edit existing event details

── delete_event.php          # Delete an event

── manage_bookings.php       # View/cancel bookings

/admin/manage_bookings.php

<?php

$conn = new mysqli("localhost", "root", "", "event_db");

$bookings = $conn->query("SELECT b.*, e.title FROM bookings b JOIN events e ON b.event_id = e.id"); 

if (isset($_GET['action']) && isset($_GET['id'])) {

    $status = $_GET['action'];

    $id = $_GET['id'];

    if (in_array($status, ['confirmed', 'cancelled'])) {

        $conn->query("UPDATE bookings SET status = '$status' WHERE id = $id");

        header("Location: manage_bookings.php");

    }

}

?>

<!DOCTYPE html>

<html>

<head><title>Manage Bookings</title></head>

<body>

    <h1>All Bookings</h1>

    <table border="1">

        <tr>

            <th>Event</th><th>User</th><th>Email</th><th>Status</th><th>Action</th>

        </tr>

        <?php while($b = $bookings->fetch_assoc()): ?>

            <tr>

                <td><?= $b['title']; ?></td>

                <td><?= $b['user_name']; ?></td>

                <td><?= $b['user_email']; ?></td>

                <td><?= $b['status']; ?></td>

                <td>

                    <a href="?action=confirmed&id=<?= $b['id']; ?>">Confirm</a> |

                    <a href="?action=cancelled&id=<?= $b['id']; ?>">Cancel</a>

                </td>

            </tr>

        <?php endwhile; ?>

    </table>

</body>

</html>


Notes:

  • Make sure to replace event_db, root, and "" with your real database, username, and password.
Tags

Post a Comment

0Comments

Post a Comment (0)