forked from fudansswebfundamental/fdu-17ss-web-lab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLab10.php
156 lines (121 loc) · 5.49 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
149
150
151
152
153
154
155
156
<?php
//Fill this place
//****** Hint ******
//connect database and fetch data here
$connection = mysqli_connect("localhost", "testuser", "mypassword", "travel");
if ( mysqli_connect_errno() ) {
die( mysqli_connect_error() );
}
//else {
// echo "连接成功";
//}
$sql = "select * from Continents";
$result = mysqli_query($connection, $sql);
$sql1 = "select * from Countries";
$result1 = mysqli_query($connection, $sql1);
?>
<!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
//****** Hint ******
//display the list of continents
while($row = $result->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
//****** Hint ******
/* display list of countries */
while($row = $result1->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
function select(){
global $continent ,$country,$connection;
global $sql2;$sql2 = "select * from ImageDetails ";
$result2 = mysqli_query($connection, $sql2);
if (isset($_GET['continent']) && isset($_GET['country'])){
$continent= $_GET['continent'];
$country = $_GET['country'];
if($continent !== "0" && $country === "0") {
global $sql2;
global $connection;
$sql2 = 'select * from ImageDetails where ContinentCode ='.'"'.$continent.'"';
$result2 = mysqli_query($connection, $sql2);
}if($continent === "0" && $country !== "0") {
global $sql2;
global $connection;
$sql2 = 'select * from ImageDetails where CountryCodeISO ='.'"'.$country.'"';
$result2 = mysqli_query($connection, $sql2);
}if($continent !== "0" && $country !== "0") {
global $sql2;
global $connection;
$sql2 = 'select * from ImageDetails where ContinentCode ='.'"'.$continent.'"'and 'CountryCodeISO ='.'"'.$country.'"';
$result2 = mysqli_query($connection, $sql2);
}
}while($row = $result2->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>
';
}
}
select();
?>
</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>