<!-- Begin Page Content -->
<div class="container-fluid">
    <div class="row column_title">
        <div class="col-md-12">
            <div class="page_title">
                <h2>Categories</h2>
            </div>
        </div>
    </div>
    <button type="button" style="float: right" onclick="location.href='<?= base_url() . 'dashboard/addcategory' ?>'" class="btn btn-primary">Add Category</button>
    <!-- DataTales Example -->
    <br><br><br>
    <div class="card shadow mb-4">
        
        <div class="card-body">
            <div class="table-responsive">
                <table class="table table-bordered" id="songTable" width="100%" cellspacing="0">
                    <thead class="thead-dark">
                        <tr>
                            <th>Seriel No.</th>
                            <th>Category</th>
                            <th>Actions</th>
                        </tr>
                    </thead>
                    <tbody>

                        <?php
                        if (!empty($categories)) {



                            $count = 1;
                            foreach ($categories as $id => $category) {
                            
                        ?>
                        <tr>
                            <td><?php echo $count; ?></td>
                            <td><?php echo $category['name']; ?></td>
                            <td>
                                <a href="<?=base_url('dashboard/editcategory/'.$id)?>">
                                    <button class="btn btn-primary btn-block mb-2">Edit</button>
                                </a>
                                <a href="<?=base_url('dashboard/deletecategory/'.$id)?>">
                                    <button class="btn btn-danger btn-block mb-2">Delete</button>
                                </a>
                            </td>

                        </tr>
                        <?php $count++; }
                        }

                        ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div 
  