1

タブレータを使用するための適切な部品をダウンロードしてインストールしました。例を示します。今、ローカルホスト データベースからデータを取得して、単純な Ajax グリッドに使用しようとしています。

これは、query.php というファイルで使用している PHP コードです。

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


$result = $db->query($db, "SELECT * FROM dataBase.table;");
if ($result) {
    $to_encode = array();
    while ($row = mysqli_fetch_assoc($result)) {
        $to_encode[] = $row;
    }
    echo json_encode($to_encode);
}

そして、これは index.html の私の HTML です

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>Bitnami: Open Source. Simplified</title>
    <link href="bitnami.css" media="all" rel="Stylesheet" type="text/css"/>
</head>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery-ui.min.js"></script>
<script type="text/javascript" src="tabulator/dist/js/tabulator.min.js">
</script>
<div id="example-table">
    <script type="text/javascript">
        $.getJSON('query.php', function (data) {
            var mydata = $.parseJSON(data);
            $("#example-table").tabulator("setData", mydata);
        });
    </script>
</div>
</body>
</html>

なんらかの理由で、空白のページが表示されます。何かアドバイスがあればお知らせください。

4

1 に答える 1