Files
2026-06-10 15:49:46 +00:00

113 lines
2.1 KiB
PHP

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
include 'koneksi.php';
echo "<h1>DATABASE AKTIF</h1>";
$db = mysqli_query($conn, "SELECT DATABASE() AS db");
$dbrow = mysqli_fetch_assoc($db);
echo "<b>Database:</b> " . $dbrow['db'];
echo "<hr>";
echo "<h1>DAFTAR TABEL</h1>";
$tables = [];
$qTables = mysqli_query($conn, "SHOW TABLES");
while ($t = mysqli_fetch_array($qTables)) {
$table = $t[0];
$tables[] = $table;
echo $table . "<br>";
}
echo "<hr>";
foreach ($tables as $table) {
echo "<h1>STRUKTUR $table</h1>";
$qDesc = mysqli_query($conn, "DESCRIBE `$table`");
echo "
<table border='1' cellpadding='5' cellspacing='0'>
<tr>
<th>Field</th>
<th>Type</th>
<th>Null</th>
<th>Key</th>
<th>Default</th>
<th>Extra</th>
</tr>
";
while ($row = mysqli_fetch_assoc($qDesc)) {
echo "<tr>";
echo "<td>{$row['Field']}</td>";
echo "<td>{$row['Type']}</td>";
echo "<td>{$row['Null']}</td>";
echo "<td>{$row['Key']}</td>";
echo "<td>{$row['Default']}</td>";
echo "<td>{$row['Extra']}</td>";
echo "</tr>";
}
echo "</table>";
echo "<br>";
echo "<h2>ISI $table (maks 10 baris)</h2>";
$qData = mysqli_query($conn, "SELECT * FROM `$table` LIMIT 10");
if ($qData && mysqli_num_rows($qData) > 0) {
echo "<table border='1' cellpadding='5' cellspacing='0'>";
$first = mysqli_fetch_assoc($qData);
echo "<tr>";
foreach (array_keys($first) as $col) {
echo "<th>$col</th>";
}
echo "</tr>";
echo "<tr>";
foreach ($first as $val) {
echo "<td>" . htmlspecialchars((string)$val) . "</td>";
}
echo "</tr>";
while ($row = mysqli_fetch_assoc($qData)) {
echo "<tr>";
foreach ($row as $val) {
echo "<td>" . htmlspecialchars((string)$val) . "</td>";
}
echo "</tr>";
}
echo "</table>";
} else {
echo "Tidak ada data.";
}
echo "<hr>";
}
?>