-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetReview.php
More file actions
34 lines (27 loc) · 876 Bytes
/
Copy pathgetReview.php
File metadata and controls
34 lines (27 loc) · 876 Bytes
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
<?php
// Database connection
$servername = "localhost";
$username = "root"; // Default XAMPP username
$password = ""; // Default XAMPP password
$dbname = "ratatutd"; // Replace with your database name
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname, "3306");
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// SQL query to fetch reviews
$sql = "SELECT Res_name, Rev_id, Rating, Rev_comment, I_comment, Username, Fav_item FROM reviews"; // Replace 'reviews' with your table name
$result = $conn->query($sql);
$reviews = array();
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$reviews[] = $row;
}
} else {
echo "0 results";
}
// Return reviews as JSON
echo json_encode($reviews);
$conn->close();
?>