-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtrybook.php
47 lines (43 loc) · 1.26 KB
/
trybook.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
<!DOCTYPE html>
<html>
<head>
<title>Tours</title>
</head>
<body>
<h2>Available Tours</h2>
<table>
<tr>
<th>ID</th>
<th>Place</th>
<th>Price</th>
<th>Description</th>
<th>Action</th>
</tr>
<?php
// Connect to the database
$servername = "localhost:3307";
$username = "root";
$password = "";
$dbname = "testdb";
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Prepare and execute the SQL statement to select all tours
$sql = "SELECT * FROM tours";
$result = $conn->query($sql);
// Loop through the results and display each tour in a row of the table
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo "<tr><td>" . $row["Id"] . "</td><td>" . $row["place"] . "</td><td>" . $row["price"] . "</td><td>" . $row["description"] . "</td><td><form action=\"final_login.php\" method=\"post\"><input type=\"hidden\" name=\"tourid\" value=\"" . $row["Id"] . "\"><input type=\"submit\" value=\"Book\"></form></td></tr>";
}
} else {
echo "No tours available";
}
// Close the database connection
$conn->close();
?>
</table>
</body>
</html>