index.php

 avatar
unknown
php
2 years ago
1.4 kB
34
Indexable
<?php

$config = mysqli_connect('localhost', 'root', '', 'eskul');

if ((!$config)) {
    # code...
    echo "error";
    die();
}

$query = 'SELECT * FROM anggota';
$datas = mysqli_query($config, $query);

?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <a href="tambah.php">tambahdata</a>
    <table border= 1>
        <thead>
            <tr>
                <th>no</th>
                <th>nama</th>
                <th>kelas</th>
                <th>jurusan</th>
                <th>nis</th>
                <th>action</th>
            </tr>
        </thead>

        <tbody>
        <?php 
        foreach ($datas as $key => $value) : ?>
        <tr>
            <td><?= $value['no'] ?></td>
            <td><?= $value['nama'] ?></td>
            <td><?= $value['kelas'] ?></td>
            <td><?= $value['jurusan'] ?></td>
            <td><?= $value['nis'] ?></td>
            <td>
            <a href="edit.php?id=<?= $value['no'] ?>">edit</a>
            <a href="delete.php?id=<?= $value['no'] ?>">delete</a>
            </td>
        </tr>
        <?php endforeach; ?>
        </tbody>
    </table>
</body>
</html>
Editor is loading...