-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpet-info.php
276 lines (256 loc) · 12.7 KB
/
pet-info.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
<?php
require_once("pdo-connect.php"); //連線到遠端資料庫
if (isset($_GET["id"])){
$id=$_GET["id"]; // pets id
}else{
header("location: pets-list.php");
}
$sqlPets="SELECT * FROM pets WHERE id=?";
$stmtPets=$db_host->prepare($sqlPets);
try{
$stmtPets->execute([$id]);
$rowPet=$stmtPets->fetch();
}catch(PDOException $e){
echo $e->getMessage();
}
$sqlProfile="SELECT * FROM pets_basic_profile WHERE created_at=(SELECT MAX(created_at)
AS maxtime FROM pets_basic_profile WHERE pet_id=?)";
//AND created_at=(SELECT MAX(created_at) FROM pets_basic_profile) 最新的毛孩數據
$stmtProfile=$db_host->prepare($sqlProfile);
try{
$stmtProfile->execute([$id]);
$rowProfile=$stmtProfile->fetch(PDO::FETCH_ASSOC);
}catch(PDOException $e){
echo $e->getMessage();
}
$sqlUser="SELECT pets.id, users.id, users.account, users.name, users.image, users.valid FROM pets
JOIN users ON pets.user_id = users.id
WHERE pets.id=?";
$stmtUser=$db_host->prepare($sqlUser);
try{
$stmtUser->execute([$id]);
$rowUser=$stmtUser->fetch();
}catch(PDOException $e){
echo $e->getMessage();
}
$user_id=$rowUser["id"];
$sqlOtherPet="SELECT id, name, img FROM pets WHERE user_id=? AND valid=1";
$stmtOtherPet=$db_host->prepare($sqlOtherPet);
try{
$stmtOtherPet->execute([$user_id]);
$rowOtherPet=$stmtOtherPet->fetchAll(PDO::FETCH_ASSOC);
}catch(PDOException $e){
echo $e->getMessage();
}
$petCount=$stmtOtherPet->rowCount();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
<meta name="Description" content="MaoBook小組專題報告"/>
<meta name="Content-Language" content="zh-TW">
<meta name="author" content="Team MaoBook"/>
<!-- 網站圖示 -->
<link rel="apple-touch-icon" type="image/png" href="images/logo-nbg.png"/>
<link rel="shortcut icon" type="image/png" href="images/logo-nbg.png"/>
<link rel="mask-icon" type="image/png" href="images/logo-nbg.png"/>
<title><?=$rowPet["name"]?>的資料</title>
<?php require_once("style.php"); ?>
<link rel="stylesheet" href="css/ou-style.css?time=<?=time()?>">
</head>
<body class="sb-nav-fixed">
<?php require_once("main-nav.php"); ?>
<!-- 主要內容 -->
<div id="layoutSidenav_content">
<div class="container px-0">
<main class="main px-5">
<div class="container-fluid px-4">
<h1 class="mt-4"><?=$rowPet["name"]?>的資料</h1>
<ol class="breadcrumb mb-4">
<li class="breadcrumb-item"><a href="home.php">首頁</a></li>
<li class="breadcrumb-item"><a href="user.php?id=<?=$rowUser["id"]?>">會員資料</a></li>
<li class="breadcrumb-item active"><?=$rowPet["name"]?>的資料</li>
</ol>
</div>
<!-- 本頁 內容 -->
<div class="row">
<div class="col-7">
<table class="table table-bordered table-sm">
<tr>
<th>毛孩姓名</th>
<td><?=$rowPet["name"]?></td>
</tr>
<tr>
<th>毛孩性別</th>
<td class="d-flex">
<div class="form-check me-3">
<input class="form-check-input" type="radio" name="flexRadioDisabled" id="flexRadioDisabled" disabled
<?php if ($rowPet["gender"]==1):
echo "checked";
endif; ?>
>
<label class="form-check-label" for="flexRadioDisabled">男孩</label>
</div>
<div class="form-check me-3">
<input class="form-check-input" type="radio" name="flexRadioDisabled" id="flexRadioDisabled" disabled
<?php if ($rowPet["gender"]==2):
echo "checked";
endif; ?>
>
<label class="form-check-label" for="flexRadioDisabled">女孩</label>
</div>
<div class="form-check me-3">
<input class="form-check-input" type="radio" name="flexRadioDisabled" id="flexRadioDisabled" disabled
<?php if ($rowPet["gender"]==9):
echo "checked";
endif; ?>
>
<label class="form-check-label" for="flexRadioDisabled">不透漏</label>
</div>
</td>
</tr>
<tr>
<th>毛孩類型</th>
<td>
<?php if($rowPet["category"]==="dog"):
echo "狗狗";
elseif($rowPet["category"]==="cat"):
echo "貓貓";
endif; ?>
</td>
</tr>
<tr>
<th>毛孩生日</th>
<td><?=$rowPet["birthday"]?>
<?php $now=date("Y-m-d");
$petBirth=$rowPet["birthday"];
$age=date_diff(date_create($now), date_create($petBirth)); ?>
<div class="data-time d-inline-block ms-3">
<?=$age->format('%y');?> 歲
</div>
</td>
</tr>
<tr>
<th>毛孩到家日</th>
<td><?=$rowPet["adopt_time"]?>
<?php $now=date("Y-m-d");
$timeDiff=strtotime($now) - strtotime($rowPet["adopt_time"]);?>
<div class="data-time d-inline-block ms-3">
已陪伴您 <?=$timeDiff / (60*60*24)?> 天
</div>
</td>
</tr>
<tr>
<th>收養類型</th>
<td><?php if($rowPet["adopt_type"]==1):
echo "接養";
elseif($rowPet["adopt_type"]==2):
echo "領養";
elseif($rowPet["adopt_type"]==3):
echo "購買";
endif; ?>
</td>
</tr>
<tr>
<th>毛孩體重</th>
<td>
<?php if(isset($rowProfile["weight"]) && $rowProfile["weight"]>0):
echo $rowProfile["weight"]; ?> kg
<div class="data-time d-inline-block ms-3">資料時間:<?=$rowProfile["created_at"]?></div>
<?php else:?>
尚未提供
<?php endif; ?>
</td>
</tr>
<tr>
<th>毛孩身高</th>
<td>
<?php if(isset($rowProfile["weight"]) && $rowProfile["height"]>0):
echo $rowProfile["height"]; ?> cm
<div class="data-time d-inline-block ms-3">資料時間:<?=$rowProfile["created_at"]?></div>
<?php else:?>
尚未提供
<?php endif; ?>
</td>
</tr>
<tr>
<th>奴才帳號</th>
<td>
<?=$rowUser["account"]?>
<?php if($rowUser["valid"]==0): ?>
<div class="data-time d-inline-block ms-1">封鎖中</div>
<?php endif; ?>
<a class="btn btn-mao-primary btn-sm ms-1"
href="user.php?id=<?=$rowUser["id"]?>">檢視會員資料</a>
</td>
</tr>
<tr>
<th>奴才姓名</th>
<td>
<?=$rowUser["name"]?>
</td>
</tr>
</table>
</div>
<div class="avatar col-5">
<div>
<h4><?=$rowPet["name"]?>的大頭照</h4>
<figure class="main-pet ratio ratio-1x1">
<?php if($rowPet["img"]!==""): ?>
<img class="cover-fit" src="images/<?=$rowPet["img"]?>" alt="">
<?php else: ?>
<img class="cover-fit" src="images/avatar_pet.png" alt="">
<?php endif; ?>
</figure>
</div>
<div>
<h4 class="mb-3">毛孩家人</h4>
<div class="d-flex flex-wrap">
<div class="position-relative me-3">
<div class="pet-info-userIcon"><i class="fas fa-user"></i></div>
<figure class="main-user ratio ratio-1x1">
<a href="user.php?id=<?=$rowUser["id"]?>">
<?php if(isset($rowUser["image"])): ?>
<img class="cover-fit" src="images/<?=$rowUser["image"]?>" alt="">
<?php else: ?>
<img class="cover-fit" src="images/avatar_user.png" alt="">
<?php endif; ?>
</a>
</figure>
<p class="text-center"><?=$rowUser["name"]?></p>
</div>
<?php if($petCount>1): ?>
<?php for($i=0; $i<=($petCount-1); $i++): ?>
<?php if($rowOtherPet[$i]["id"]!==$rowPet["id"]):?>
<div class="position-relative me-3">
<div class="pet-info-petIcon"><i class="fas fa-paw"></i></div>
<figure class="sub-pet ratio ratio-1x1">
<a href="pet-info.php?id=<?=$rowOtherPet[$i]["id"]?>">
<?php if($rowOtherPet[$i]["img"]!==""):?>
<img class="cover-fit" src="images/<?=$rowOtherPet[$i]["img"]?>"
alt="">
<?php else: ?>
<img class="cover-fit" src="images/avatar_pet.png" alt="">
<?php endif; ?>
</a>
</figure>
<p class="text-center"><?=$rowOtherPet[$i]["name"]?></p>
</div>
<?php endif; ?>
<?php endfor; ?>
<?php endif; ?>
</div>
</div>
</div>
</div>
<!-- 本頁內容 end -->
</main><!-- 主要內容end -->
</div>
<!-- --><?php //require_once("footer.php"); ?>
</div>
<?php require_once("JS.php"); ?>
</body>
</html>