-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrefine.php
74 lines (72 loc) · 2.33 KB
/
refine.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
function h($str){
return htmlspecialchars($str, ENT_QUOTES, 'UTF-8');
}
?>
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>絞り込み</title>
<link rel=stylesheet href="main.css" type="text/css" charset="utf-8" />
<script src="jq/jquery-3.2.1.js" type="text/javascript"></script>
<script src="jq/jquery.tablesorter.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#booksTable").tablesorter();
}
);
</script>
</head>
<body>
<?php
try{
require_once 'DbManager.php';
$db = getDb();
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
}catch(PDOException $Exception){
die('接続エラー:' .$Exception->getMessage());
}
try{
$column = $_GET['column'];
$char = $_GET['text'];
$sql = "SELECT * FROM 一般 WHERE $column LIKE '%$char%'";
$stmh = $db->prepare($sql);
$stmh->execute();
}catch(Exception $Exception){
echo '検索エラー:' .$Exception->getMessage();
die();
}
?>
<h1>絞り込み <?php echo $h($_GET['column']).": ".$h($_GET['text']) ?></h1>
<table class="books">
<thead>
<tr>
<th>タイトル</th>
<th>著者</th>
<th>イラスト</th>
<th>出版</th>
<th>種別</th>
</tr>
</thead>
<tbody>
<?php
while($row = $stmh->fetch(PDO::FETCH_ASSOC)){
?>
<tr>
<td><a href="edit.php?id=<?=$h($row['蔵書番号'])?>"><?=$h($row['タイトル'])?></a></th>
<td><a href="refine.php?column=著者&text=<?=$h($row['著者'])?>"><?=$h($row['著者'])?></a></th>
<td><a href="refine.php?column=イラスト&text=<?=$h($row['イラスト'])?>"><?=$h($row['イラスト'])?></a></th>
<td><a href="refine.php?column=出版&text=<?=$h(['出版'])?>"><?=$h($row['出版'])?></a></th>
<td><a href="refine.php?column=種別&text=<?=$h($row['種別'])?>"><?=$h($row['種別'])?></a></th>
</tr>
<?php
}
$db = null;
?>
</tbody>
</table>
<a href="./">一覧に戻る</a>
</body>
</html>