<html>
<head>
<script type="text/JavaScript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/JavaScript">
$(function() {
$("#buttonId#).click(function() {
$("#divToUpdate").load("/scriptPhp.php");
});
</script>
</head>
<body>
<input id="buttonId" type="button" value="click me!" />
<br />
<div id="divToUpdate">
</div>
</body>
</html>
そして scriptPHP.php ファイルで:
<table>
<thead>
<tr>
<th>Cell 1</th>
<th>Cell 2</th>
</tr>
</thead>
<tbody>
<?php
$pdo = new Pdo("mysql:host=localhost;dbname=nameOfTheDatabase;charset=utf8", "username", "password");
$rows = $pdo->query("SELECT * FROM tablename")->fetchAll(PDO::FETCH_ASSOC);
foreach ($rows as $row) {
?>
<tr>
<td><?php echo $row['cell_1']; ?></td>
<td><?php echo $row['cell_2']; ?></td>
</tr>
<?php
}
?>
</table>