connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// data analysis
$query = "SELECT attraction_id, COUNT(attraction_id) AS attribute_count FROM attraction_booking GROUP BY attraction_id ORDER BY attribute_count DESC LIMIT 1";
$result = $conn->query($query);
if ($result->num_rows > 0) {
$row = $result->fetch_assoc();
$most_common_attribute_value = $row['attraction_id'];
// the most popular,times
echo "The most popular attraction is:" . $most_common_attribute_value . ",the times is:" . $row['attribute_count'] . " ";
// all information
$query_all_info = "SELECT * FROM attraction_booking JOIN attraction USING(attraction_id) WHERE attraction_id = '$most_common_attribute_value'";
$result_all_info = $conn->query($query_all_info);
if ($result_all_info->num_rows > 0) {
echo '
';
echo '
';
echo '
attraction_id
Name
';
while ($row_info = $result_all_info->fetch_assoc()) {
echo '
';
echo '
' . $row_info['attraction_id'] . '
';
echo '
' . $row_info['name'] . '
';
echo '
';
}
echo '
';
} else {
echo 'No information found for the most common attribute value.';
}
} else {
echo "No records found";
}
?>
connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// data analysis
$query = "SELECT restaurant_id, COUNT(restaurant_id) AS restaurant_count FROM restaurant_booking GROUP BY restaurant_id ORDER BY restaurant_count DESC LIMIT 1";
$result = $conn->query($query);
if ($result->num_rows > 0) {
$row = $result->fetch_assoc();
$most_common_attribute_value = $row['restaurant_id'];
$query_all_info = "SELECT * FROM restaurant_booking JOIN restaurant USING(restaurant_id) WHERE restaurant_id = '$most_common_attribute_value'";
$result_all_info = $conn->query($query_all_info);
if ($result_all_info->num_rows > 0) {
echo '
';
echo '
';
echo '
restaurant_id
Name
';
echo "
The most popular restaurant is:" . $most_common_attribute_value . ",the times is:" . $row['restaurant_count'] . "
";
while ($row_info = $result_all_info->fetch_assoc()) {
echo '
';
echo '
' . $row_info['restaurant_id'] . '
';
echo '
' . $row_info['name'] . '
';
echo '
';
}
echo '
';
} else {
echo 'No information found for the most common attribute value.';
}
} else {
echo "No records found";
}
// Close database connection
$conn->close();
?>