forked from fudansswebfundamental/fdu-17ss-web-lab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLab10.php
148 lines (121 loc) · 5.34 KB
/
Lab10.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
<?php
//Fill this place
$db = new mysqli('localhost', 'root', 'dadk15dd&ka', 'travel');
if (!$db) {
throw new Exception( "无法连接到数据库");
}
//****** Hint ******
//connect database and fetch data here
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Chapter 14</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href='http://fonts.googleapis.com/css?family=Lobster' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="css/bootstrap.min.css" />
<link rel="stylesheet" href="css/captions.css" />
<link rel="stylesheet" href="css/bootstrap-theme.css" />
</head>
<body>
<?php include 'header.inc.php'; ?>
<!-- Page Content -->
<main class="container">
<div class="panel panel-default">
<div class="panel-heading">Filters</div>
<div class="panel-body">
<form action="Lab10.php" method="get" class="form-horizontal">
<div class="form-inline">
<select name="continent" class="form-control">
<option value="0">Select Continent</option>
<?php
//Fill this place
$query = "select * from continents";
$stmt = $db->query($query);
//****** Hint ******
//display the list of continents
while($row = $stmt->fetch_assoc()) {
echo '<option value=' . $row['ContinentCode'] . '>' . $row['ContinentName'] . '</option>';
}
?>
</select>
<select name="country" class="form-control">
<option value="0">Select Country</option>
<?php
//Fill this place
$query = "select * from countries";
$stmt = $db->query($query);
//****** Hint ******
/* display list of countries */
while($row = $stmt->fetch_assoc()) {
echo '<option value=' . $row['ISO'] . '>' . $row['CountryName'] . '</option>';
}
?>
</select>
<input type="text" placeholder="Search title" class="form-control" name=title>
<button type="submit" class="btn btn-primary">Filter</button>
</div>
</form>
</div>
</div>
<ul class="caption-style-2">
<?php
//Fill this place
$continent = isset($_GET['continent'])? trim($_GET['continent']) : "0";
$country = isset($_GET['country'])? trim($_GET['country']) : "0";
$query = "select * from imagedetails";
if($continent === "0" && $country === "0") {
$query = "select * from imagedetails";
} else if ($continent === "0" && $country !== "0") {
// $query = "select * from imagedetails where CountryCodeISO = '".$country."'";
$query .= " where CountryCodeISO = '".$country."'";
} else if ($continent !== "Select Continent" && $country === "0") {
$query .= " where ContinentCode = '".$continent."'";
} else {
$query .= " where CountryCodeISO = '".$country."' and ContinentCode = '".$continent."'";
}
$stmt = $db->query($query);
//****** Hint ******\
while($row = $stmt->fetch_assoc()){
echo '<li>
<a href="detail.php?id='.$row["ImageID"].'" class="img-responsive">
<img src="images/square-medium/'.$row["Path"].'" alt="'.$row["Title"].'">
<div class="caption">
<div class="blur"></div>
<div class="caption-text">
<p>'.$row["Description"].'</p>
</div>
</div>
</a>
</li>';
}
/* use while loop to display images that meet requirements ... sample below ... replace ???? with field data
<li>
<a href="detail.php?id=????" class="img-responsive">
<img src="images/square-medium/????" alt="????">
<div class="caption">
<div class="blur"></div>
<div class="caption-text">
<p>????</p>
</div>
</div>
</a>
</li>
*/
?>
</ul>
</main>
<footer>
<div class="container-fluid">
<div class="row final">
<p>Copyright © 2017 Creative Commons ShareAlike</p>
<p><a href="#">Home</a> / <a href="#">About</a> / <a href="#">Contact</a> / <a href="#">Browse</a></p>
</div>
</div>
</footer>
<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
</body>
</html>