-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathread.php
67 lines (54 loc) · 1.41 KB
/
read.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
<?php
$dsn = 'mysql:dbname=game;host=localhost;port=3306;charset=utf8';
$user='uk';
$password='1234';
class Json {
public $id;
public $power;
public $syateki_score;
public $stamina;
public $score1;
public $score2;
public $speed;
public $name;
function __construct($id,$score1,$score2,$speed,$stamina,$syateki_score,$power,$name) {
$this->id = $id;
$this->power = $power;
$this->stamina = $stamina;
$this->score1 = $score1;
$this->score2 = $score2;
$this->speed = $speed;
$this->syateki_score = $syateki_score;
$this -> name=$name;
}
}
try{
$idm=$_GET['idm'];
$dbh = new PDO($dsn,$user,$password);
$sql =
$dbh->prepare('select * from status where idm = ? AND exist=1');
$sql->bindValue(1,$idm);
$sql->execute();
$all = $sql->fetchAll();
foreach ($all as $data)
{
$Jsond=new Json(
$data['id'],
$data['score1'],
$data['score2'],
$data['speed'],
$data['stamina'],
$data['syateki_score'],
$data['power'],
$data['name']
);
}
//jsonとして出力
header('Content-type: application/json');
echo json_encode($Jsond);
}catch (PDOException $e){
print('Error:'.$e->getMessage());
die();
}
$dbh = null;
?>