<?php

include ("db.php");

$result = $conn->query("SELECT * FROM registrations");
?>

<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Administrator | Manage Registrations</title>
    <link href="css/bootstrap.css" rel="stylesheet" />
    <link href="css/style.css" rel="stylesheet" />
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css' />
</head>
<body>
<div id="wrapper">
    <?php include("top-header.php"); include("right-sec.php"); ?>
    <div id="page-wrapper">
        <div id="page-inner">
            <div class="row">
                <div class="col-md-12">
                    <h3 class="page-header">Manage Registrations</h3>
                    <div class="table-sec">
                        <table class="table table-striped">
                            <tr>
                                <th>Id</th>
                                <th>Parent Name</th>
                                <th>Email</th>
                                <th>Phone</th>
                                <th>Student Name</th>
                                <th>Category</th>
                                <th>DOB</th>
                                <th>Start Date</th>
                                <th>Actions</th>
                            </tr>
                            <?php while ($row = mysqli_fetch_assoc($result)) {
                            $selectcategorylist=$conn->query("SELECT * FROM course_category where id='".$row['category']."'");
                            $rowcat = mysqli_fetch_assoc($selectcategorylist)
                            ?>
                            <tr>
                                <td><?php echo $row['id']; ?></td>
                                <td><?php echo $row['parent_first_name'] . ' ' . $row['parent_last_name']; ?></td>
                                <td><?php echo $row['parent_email']; ?></td>
                                <td><?php echo $row['parent_phone']; ?></td>
                                <td><?php echo $row['student_first_name'] . ' ' . $row['student_last_name']; ?></td>
                                <td><?php echo $rowcat['course']; ?></td>
                                <td><?php echo $row['dob']; ?></td>
                                <td><?php echo $row['start_date']; ?></td>
                                <td>
                                    <a href="update-registration.php?id=<?php echo $row['id']; ?>" class="btn btn-primary btn-sm"><i class="fa fa-pencil"></i> Edit</a>
                                    <a href="delete-registration.php?id=<?php echo $row['id']; ?>" class="btn btn-danger btn-sm" onclick="return confirm('Are you sure?')"><i class="fa fa-trash"></i> Delete</a>
                                </td>
                            </tr>
                            <?php } ?>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <footer class="footer-sec">
        <div class="container">
            <div class="row">
                <div class="col-md-12">
                    <p class="text-center">All right reserved. Template Design by: <a href="">DNPI</a></p>
                </div>
            </div>
        </div>
    </footer>
</div>
<script src="js/jquery-1.10.2.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery.metisMenu.js"></script>
<script src="js/custom-scripts.js"></script>
</body>
</html>
<?php $conn->close(); ?>
