<?php
require '../functions.php';

$keyword = $_GET["keyword"];

$query = "SELECT * FROM user WHERE 
                username LIKE '%$keyword%' OR
				nama LIKE '%$keyword%' 
                ";
$akun = query($query);
?>
<style>
    .iii {
        width: 100px;
        height: 100px;
    }
</style>
<table class="table table-striped">
    <thead>
        <tr>
            <th scope="col">No.</th>
            <th scope="col">Aksi</th>
            <th scope="col">Photo</th>
            <th scope="col">Nama</th>
            <th scope="col">Alamat</th>
            <th scope="col">NIM</th>
            <th scope="col">Tempat/Tanggal Lahir</th>
            <th scope="col">Jenis Kelamin</th>
            <th scope="col">No. Telepon</th>
            <th scope="col">Email</th>
            <th scope="col">Pekerjaan</th>
            <th scope="col">Username</th>
            <th scope="col">Password</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <?php $i = 1 ?>
            <?php foreach ($akun as $row) : ?>
                <td><?php echo $i; ?></td>
                <td>
                    <?php $level = $row["level"] == 'admin';
                    if (!$level) : ?>
                        <a href="ubah.php?id=<?php echo $row["id"] ?>">ubah</a> |
                        <a href="hapus.php?id=<?php echo $row["id"] ?>" onclick="return confirm('yakin?');">hapus</a>
                    <?php endif; ?>
                </td>
                <td>
                    <?php $level = $row["level"] == 'admin';
                    if (!$level) : ?>
                        <img class="iii" src="img/<?php echo $row["gambar"] ?>">
                    <?php endif; ?>
                </td>
                <td><?= $row["nama"]; ?></td>
                <td><?= $row["alamat"]; ?></td>
                <td><?= $row["nim"]; ?></td>
                <td><?= $row["TTL"]; ?></td>
                <td><?= $row["jenis"]; ?></td>
                <td><?= $row["telepon"]; ?></td>
                <td><?= $row["email"]; ?></td>
                <td><?= $row["pekerjaan"]; ?></td>
                <td><?= $row["username"] ?></td>
                <td>***********</td>
        </tr>
        <?php $i++; ?>
    <?php endforeach; ?>
    </tbody>
</table>