<?php
    include '../back/wildlife_database/connection.php';
?>
<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Afar.TV - Namib Desert - Wildlife Adder</title>
        <?php include '../../../includes/head.php';?>  
        <link src="https://cdn.datatables.net/1.11.3/css/jquery.dataTables.min.css" rel="stylsheet">
        <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>] 
        <script src="https://cdn.datatables.net/1.11.3/js/jquery.dataTables.min.js"></script>
    </head>
    <body class="full-wrap theme-dark">

        <div class="main-wrapper">
            <!-- header wrapper -->
            <?php include '../../../includes/header.php';?>   
            <!-- header wrapper -->
            <!-- banenr wrapper -->
            <div class="page-nav" id="team">
                <div class="container">
                    <style>
                        .table{
                            color:#fff !important;
                            /* width: 60% !important;  */
                            margin: auto!important;
                        }
                        hr{
                            border-top: 1px solid #dee2e6 !important;
                        }
                        .table tr:first-child td{
                            border-top:unset !important;
                        }
                        #myTable_length,#myTable_info{
                            display: inline-block;
                            float: left;
                            color: #fff;
                        }
                        #myTable_filter,#myTable_paginate{
                            display: inline-block;
                            float: right;
                            color: #fff;
                        }
                        #myTable_paginate a {
                            margin: 0px 5px;
                        }
                    </style>
                    <div style="width:60%; margin:0px auto;" class="table-responsive">
                        <table class="table table-sm" id="myTable">
                            <thead>
                                <tr>
                                    <th>id</th>
                                    <th>Species</th>
                                </tr>
                            </thead>                    
                            <tbody>                            
                                <?php 
                                $sql = "SELECT `species`.`id`,`species`.`species_name` FROM `species` order by species.id ASC";	
                                        
                                $result = $conn->query($sql);
                                if ($result->num_rows > 0) {
                                    while($row = $result->fetch_assoc()) {
                                        echo "<tr>";
                                        echo "<td>".$row['id']."</td>";
                                        echo "<td>".$row['species_name']."</td>"; 
                                        echo "</tr>";
                                    }// end while loop
                                }else{
                                echo "<tr><td colspan='2' class='text-center border-0'>No Species Found.</td></tr>";
                                }
                                ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
            <script>
                $(document).ready( function () {
                    $('#myTable').DataTable({
                        "pageLength": 50,
                        "lengthMenu": [[50, 100, 150, -1], [50, 100, 150, "All"]]
                    });
                } );
            </script>
            <!-- footer wrapper -->
            <?php include '../../../includes/footer.php';?>   
            <!-- footer wrapper -->
            
        </div>
    </body>
</html>