-
Notifications
You must be signed in to change notification settings - Fork 0
/
json_copy.php
88 lines (72 loc) · 2.12 KB
/
json_copy.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
require_once('config.php');
require_once('functions.php');
mb_language("uni");
mb_internal_encoding("utf-8"); //内部文字コードを変更
mb_http_input("auto");
mb_http_output("utf-8");
if (isset($_POST['read'])) {
$post = htmlspecialchars($_POST['read']);
// ---- ユーザーレビュー
$dbh = connectDb();
$sth1 = $dbh->prepare("SELECT * FROM filmarks ORDER BY review_date DESC LIMIT $post, 1");
$sth1->execute();
$userData = array();
while($row = $sth1->fetch(PDO::FETCH_ASSOC)){
$userData[]=array(
'c_fav' =>$row['c_fav'],
'fav' =>$row['fav'],
'watch' =>$row['watch'],
'want' =>$row['want'],
'title_no' =>$row['title_no'],
'user_no' =>$row['user_no'],
'user_name' =>$row['user_name'],
'user_img' =>$row['user_img'],
'title' =>$row['title'],
'title_img' =>$row['title_img'],
'comment' =>$row['comment'],
'review_date'=>$row['review_date'],
'rating' =>$row['rating']
);
}
header('Content-Type/json: application/json');
echo "{filmarks: ".json_encode($userData)."}";
} elseif (isset($_POST['list'])) {
// ---- ユーザー登録映画の取得
$post = htmlspecialchars($_POST['list']);
$sql = '
SELECT
title AS title,
title_origin AS title_origin,
title_no AS title_no,
year AS year,
country AS country,
duration AS duration,
director AS director,
writter AS writter,
cast AS cast
FROM movie LIMIT $post, 3
';
header('Content-Type/json: application/json');
echo "{filmarks: ".json_encode(connectDb()->query($sql)->fetchAll(PDO::FETCH_ASSOC))."}";
} elseif (isset($_POST['grid3'])) {
$post = htmlspecialchars($_POST['grid3']);
$number = 3;
getSql($post,$number);
} elseif (isset($_POST['grid4'])) {
$post = htmlspecialchars($_POST['grid4']);
$number = 4;
getSql($post,$number);
} elseif (isset($_POST['grid5'])) {
$post = htmlspecialchars($_POST['grid5']);
$number = 5;
getSql($post,$number);
} elseif (isset($_POST['info'])) {
// ---- 映画情報の取得
$post = htmlspecialchars($_POST['info']);
getMovieInfo($post);
// getSql(0,2);
} else {
$post = 'error';
}
?>