-
Notifications
You must be signed in to change notification settings - Fork 0
/
place.php
137 lines (117 loc) · 5.58 KB
/
place.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
<?php
error_reporting(0);
require('common/document-head.php');
?>
<title>Place</title>
<link href="./css/style-place.css" rel="stylesheet">
</head>
<?php
use MongoDB\Client;
require_once "vendor/autoload.php";
$conn = new Client("mongodb+srv://kimnhu:[email protected]/?serverSelectionTryOnce=false&serverSelectionTimeoutMS=15000&w=majority");
$db = $conn->IE104_PROJECT;
$post = $db->POST;
$province = $db->PROVINCE;
?>
<body>
<!----------------------------Header--------------------------->
<?php
require('common/header.php');
?>
<!----------------------------Header-------------------------------->
<main>
<section class="head-content">
<div class="container">
<h1>Places to go</h1>
<p>Get an insider look at Vietnam’s best destinations.</p>
</div>
</section>
<div class="centered">
<h1>Urban Hubs</h1>
<p>Each Vietnamese city exudes its own distinct character.
<br> Get a feel for Vietnam’s fascinating urban centres in these interactive tours.
<br>Let these local Vietnamese show you around their hometowns with personal stories, top tips, and
must-do experiences.
</p>
</div>
<div class="filter">
<!-- <form action="place.php" method="POST">
<button class="all" name="search_all">ALL</button>
</form> -->
<div class="search-container">
<form action="place.php" method="POST">
<!-- <input type="text" placeholder="Search.." name="search"> -->
<div class="form-group" >
<select style="display: inline-block; padding: 20px; width: 200px;" id="province" name="province" value="selected">
<?php
$pro = $province->find();
foreach($pro as $row) {
?>
<option <?php if($_SERVER["REQUEST_METHOD"] == "POST") if($_POST["province"] == (int) $row->provinceid) echo "selected";?> value="<?php echo $row->provinceid;?>"><?php echo $row->name;?></option>
<?php
}
?>
</select>
</div>
<button style="display: inline-block;" type="submit" name="search"><i class="fas fa-search"></i></button>
</form>
</div>
</div>
<div class="content-container">
<?php
if($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['search'])) {
$search_post_ = $post->find(['provinceid' => (int) $_POST['province']]);
$num_post = 0;
foreach($search_post_ as $row) {
$num_post++;
}
if (isset($_GET['pageno'])) {
$pageno = $_GET['pageno'];
} else {
$pageno = 1;
}
$no_of_records_per_page = 4;
$offset = ($pageno-1)*$no_of_records_per_page;
$rec_count = $num_post;
$total_pages = ceil($rec_count/$no_of_records_per_page);
$search_post = $post->find(['provinceid' => (int) $_POST['province']]);
foreach($search_post as $row) {
?>
<div class="place">
<div class="place-img">
<a href="blog-content.php?postid=<?php echo $row->postid;?>"><img src="./image/<?php echo $row->img[0];?>" alt="<?php echo $row->title;?>"></a>
</div>
<div class="place-intro">
<h1 class="title">
<a href="blog-content.php?postid=<?php echo $row->postid;?>"><?php echo $row->title;?></a>
</h1>
<p class="introduce"><?php echo $row->description;?></p>
</div>
</div>
<?php
}
?>
<div class="pagination flex-row">
<a href="#"><i class="fas fa-chevron-left"></i></a>
<a href="<?php if($pageno <= 1){ echo '#'; } else { echo "?pageno=".($pageno - 1); } ?>" class="pages">
<?php if($pageno <= 1){ echo '...'; } else { echo ($pageno - 1); } ?>
</a>
<a href="<?php echo "?pageno=".($pageno); ?>" class="pages"><?php echo $pageno;?></a>
<a href="<?php if($pageno >= $total_pages){ echo '#'; } else { echo "?pageno=".($pageno + 1); } ?>" class="pages">
<?php if($pageno >= $total_pages){ echo '...'; } else { echo ($pageno + 1); } ?>
</a>
<a href="#"><i class="fas fa-chevron-right"></i></a>
</div>
<?php
}
// if(isset($_POST['search_all'])) {
// }
?>
</div>
</main>
<!------------------------------Footer---------------------------------------------------->
<?php
require('common/footer.php');
?>
<!------------------------------Footer---------------------------------------------------->
</body>