<?php
require_once("db/functions.php");
require_once("db/db-const.php");

$mysqli = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
$mysqli->set_charset("utf8");

$sql = "SELECT * from image_organes ORDER BY nom ASC";
$organes = $mysqli->query($sql);

/*$sql = "SELECT * from image_pathologie ORDER BY nom ASC";
$pathologies = $mysqli->query($sql);*/


?>


<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<?php include 'includes/head.php'; ?>
<body>
<?php include 'includes/header.php'; ?>
<!-- LOGO HEADER END-->
<?php include 'includes/navbar.php'; ?>
<!-- MENU SECTION END-->

<div class="tab-content">
    <div class="container">
        <div class="row" style="margin-top:15px">

            <?php
            $clause = "AND audience = 'public'";
            if(logged_in())
                $clause = "";

             while ($organe = $organes->fetch_assoc()) {
                $typeId = $organe["id"];
                $count = array_values(mysqli_fetch_array($mysqli->query("SELECT COUNT(*) as total FROM image_table where typePhototheque='Organe' $clause AND idTypeImage = $typeId ")))[0];
                ?>
                <div class="col-md-4" style="margin-bottom: 20px; padding-left: 20px; padding-right: 20px">
                    <a href="images.php?type=Organe&id=<?= $typeId ?>" class="btn btn-success btn-block"
                       role="button"><?= $organe["nom"] ?> <span class="badge pull-right"><?=$count?></span> </a>
                </div>
            <?php } ?>


            <!--                    <?php /*while ($pathologie = $pathologies->fetch_assoc()) { */ ?>
                        <option value="<? /*= $pathologie["id"] */ ?>" ><? /*= $pathologie["nom"] */ ?></option>
                    <?php /*} */ ?>
                    -->

        </div>
    </div>

    <script src="js/jquery.min.js"></script>

</div>

<?php include 'includes/footer-scripts.php'; ?>
</body>
</html>


