-
Notifications
You must be signed in to change notification settings - Fork 10
/
viewjourney.php
94 lines (78 loc) · 2.63 KB
/
viewjourney.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
<?php
// Database connection parameters
$servername = "localhost"; // Change this to your database server name
$username = "root"; // Change this to your database username
$password = ""; // Change this to your database password
$dbname = "travelscapes"; // Change this to your database name
// Create a connection to the database
$conn = new mysqli($servername, $username, $password, $dbname);
// Check the connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Initialize variables
$cityId = $_GET['city_id']; // Assuming you pass the city ID in the URL
// Fetch city details from the database
$sql = "SELECT * FROM cities WHERE cityid = $cityId";
$result = $conn->query($sql);
$folderPath = './Places/';
$allowedExtensions = array('jpg', 'jpeg', 'png', 'gif');
$imageArray = array();
// Retrieve image files from the folder
$files = scandir($folderPath);
foreach ($files as $file) {
$fileInfo = pathinfo($file);
$extension = strtolower($fileInfo['extension']);
if (in_array($extension, $allowedExtensions)) {
// It's an image file, so add it to the array
$imageArray[] = $folderPath . $file;
}
}
if ($result->num_rows > 0) {
$row = $result->fetch_assoc();
$city = $row['city'];
$region = $row['region'];
$season = $row['season'];
$days = $row['days'];
$cost = $row['cost'];
} else {
echo "City not found.";
exit();
}
?>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="./css/viewjourney.css">
<title><?php echo $city; ?> Details</title>
</head>
<body>
<div class="navbar">
<span class="logo">Travelscapes</span>
</div>
<div class="content-container">
<h1>>> <?php echo $city; ?> << </h1>
<div class="city-card">
<div class="city-images">
<img src="<?php echo $imageArray[$cityId-1]; ?>" alt="Image Alt Text">
</div>
<div class="city-details">
<p><strong>City:</strong> <?php echo $city; ?></p>
<p><strong>Region:</strong> <?php echo $region; ?></p>
<p><strong>Season:</strong> <?php echo $season; ?></p>
<p><strong>Days:</strong> <?php echo $days; ?></p>
<p><strong>Cost:</strong> Rs <?php echo $cost; ?></p>
</div>
<div class="view-hotels-button">
<a href="view_hotels.php?city_id=<?php echo $cityId; ?>" class="view-button">View Hotels</a>
</div>
</div>
<?php
$conn->close();
?>
</div>
<footer>
<p>© 2023 Travelscapes. All rights reserved.</p>
</footer>
</body>
</html>