<?php

    if (isset($_GET['delete'])){

        $use->delete('advise_videos',$_GET['delete']);

        echo "<script>location='./?page=advises'</script>";

    }

?>

<div class="row">

    <div class="col-md-12">

        <div class="card">

            <div class="card-header bg-transparent">

                <div class="row align-items-center">

                    <div class="col">

                        <h6 class="text-uppercase text-muted ls-1 mb-1">List Advises | <a class="btn btn-primary"

                                                                                           href="./?page=advise-new">New</a></h6>

                    </div>

                </div>

            </div>

            <div class="card-body">
				<h4><?=isset($_GET['message'])?$_GET['message']:''?></h4>
                <table class="table table-striped" id="myTable">

                    <thead>

                    <tr>

                        <th width="50">#</th>

						<th>Title</th>
						<th>Link</th>
						
                        <th>Action</th>

                    </tr>

                    </thead>

                    <tbody>

                    <?php foreach ($use->getAllAdvises() as $advise): 

                        

                    ?>

                        <tr>

                            <td>#</td>

                            
                            <td><?= $advise['title'] ?></td>
                            <td><a href="<?= $advise['ylink'] ?>" target="_blank"><?= $advise['ylink'] ?></a></td>

                            <td width="150">

                                <a href="./?page=advises&delete=<?= $advise['id'] ?>" class="btn btn-danger btn-sm">Delete</a>

                                <a href="./?page=advises-edit&id=<?= $advise['id'] ?>" class="btn btn-info btn-sm">Edit</a>

                            </td>

                        </tr>

                    <?php endforeach; ?>

                    </tbody>

                </table>

            </div>

        </div>

    </div>

</div>