<?php
    if(isset($_POST['delete'])){
        $id = $_POST['delete_transcript'];

        $all_transcript = "DELETE FROM transcript WHERE transcript_id=$id";

        if($db->query($all_transcript) == TRUE){
            echo "<script>alert('transcript Deleted')</script>";
        }else{
            echo "<script>alert('transcript not deleted')</script>";
        }

    }

?>
    
            <!-- Recent Sales Start -->
            <div class="container-fluid pt-4 px-4">
                <div class="bg-secondary text-center rounded p-4">
                    <div class="d-flex align-items-center justify-content-between mb-4">
                        <h6 class="mb-0">Transcript</h6>
                        
                    </div>
                    <div class="table-responsive">
                      <div class="container">
                        <div class="row">
                            <div class="col-md-12">
                                 <!-- view all transcript  -->
                               <table class="table text-start align-middle table-bordered table-hover mb-0" style="margin-top:50px;">
                                    <thead>
                                        <tr>
                                            <th scope="col">S/N</th>
                                            <th scope="col">Student Name</th>
                                            <th scope="col">Matric Number</th>
                                            <th scope="col">Sex</th>
                                            <th scope="col">Program Type</th>
                                            <th scope="col">Date Of Birth</th>
                                            <th scope="col">Email</th>
                                            <th scope="col">Phone</th>
                                            <th scope="col">School</th>
                                            <th scope="col">Department</th>
                                            <th scope="col">Class of Degree</th>
                                            <th scope="col">Reason for Transcript Request</th>
                                            <th scope="col">Transcipt Type</th>
                                            <th scope="col">Action</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php
                                            $all_transcript = mysqli_query($db, "SELECT * FROM transcript");

                                            // fetch all carry over 
                                            if(mysqli_fetch_array($all_transcript)){
                                                
                                                // use foreach loop to echo all data
                                                foreach($all_transcript as $transcript){
                                        ?>
                                        <tr>
                                                <td><?php echo $transcript['transcript_id']; ?></td>
                                                <td><?php echo $transcript['sname']; ?></td>
                                                <td><?php echo $transcript['mat']; ?></td>
                                                <td><?php echo $transcript['sex']; ?></td>
                                                <td><?php echo $transcript['program_type']; ?></td>
                                                <td><?php echo $transcript['dob']; ?></td>
                                                 <td><?php echo $transcript['email']; ?></td>
                                                  <td><?php echo $transcript['phone']; ?></td>
                                                  <td><?php echo $transcript['school']; ?></td>
                                                  <td><?php echo $transcript['dept']; ?></td>
                                                  <td><?php echo $transcript['class']; ?></td>
                                                  <td><?php echo $transcript['reasonoftran']; ?></td>
                                                  <td><?php echo $transcript['Transcipt']; ?></td>
                                                  
                                                  
                                                <!-- <td><a class="btn btn-sm btn-success" href="index.php?env=edit_transcript&transcript_id=<?php echo $transcript['transcript_id']; ?>">Edit</a></td> -->
                                                <td>
                                                    <form method="POST">
                                                        <input type='hidden' name='delete_transcript' value='<?php echo $transcript['transcript_id']; ?>'>
                                                        <input type='submit'class='btn btn-sm btn-danger' name='delete' value='Delete'>
                                                    </form>
                                          
                                                </td>
                                        </tr>
                                        <?php
                                            }
                                        }
                                        ?>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                      </v>
                    </div>
                </div>
            </div>
            <!-- Recent Sales End -->

            <!-- Footer Start -->
         <?php include("inc/footer.php"); ?>
