8-1.php
来自「《php程序设计》的配套源码 《php程序设计》的配套源码 《php程序」· PHP 代码 · 共 39 行
PHP
39 行
<html><head><title>Bond Movies</title></head>
<body>
<table border=1>
<tr><th>Movie</th><th>Year</th><th>Actor</th></tr>
<?php
// connect
require_once('DB.php');
$db = DB::connect("mysql://user:seekrit@localhost/bondb");
if (DB::iserror($db)) {
die($db->getMessage());
}
// issue the query
$sql = "SELECT movies.title,movies.year,actors.name
FROM movies,actors
WHERE movies.actor=actors.id
ORDER BY movies.year ASC";
$q = $db->query($sql);
if (DB::iserror($q)) {
die($q->getMessage());
}
// generate the table
while ($q->fetchInto($row)) {
?>
<tr><td><?= $row[0] ?></td>
<td><?= $row[1] ?></td>
<td><?= $row[2] ?></td>
</tr>
<?php
}
?>
</table>
</body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?