<?php
$conn = new mysqli('localhost', 'root', '', 'siakad');
if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); }

$res = $conn->query("SHOW TABLES LIKE 'ref_wilayah'");
if ($res->num_rows > 0) {
    echo "Table ref_wilayah exists!\n";
    $count = $conn->query("SELECT COUNT(*) as c FROM ref_wilayah")->fetch_assoc();
    echo "Rows: " . $count['c'] . "\n";
} else {
    echo "Table ref_wilayah DOES NOT EXIST!\n";
}
$conn->close();
