我有以下 PHP 文件,它运行良好,所有输出都显示出来,但是 IF 语句有问题。我不知道为什么它同时显示 IF 语句和两行星星的所有文本(字体真棒图标).为什么会这样,有人可以帮助我吗?谢谢
<?php
include('database_connection.php');
if(isset($_POST["action"]))
{
$query = "
SELECT * FROM items WHERE product_status = '1'
";
if(isset($_POST["brands"]))
{
$brand_filter = implode("','", $_POST["brands"]);
$query .= " AND product BETWEEN '400' AND '600' ";
}
$statement = $connect->prepare($query);
$statement->execute();
$result = $statement->fetchAll();
$total_row = $statement->rowCount();
$output = '';
if($total_row > 0)
{
foreach($result as $row)
{
$output .= '
<div class="col-sm-4 col-lg-3 col-md-3">
<div style="border:1px solid #ccc; border-radius:5px; padding:16px; margin-bottom:16px; height:450px;">
<p align="center"><strong><a href="#">'. $row['hotel_name'] .'</a></strong></p>
<h4 style="text-align:center;" class="text-danger" >'. $row['product_price'] .'</h4>
if($row["rating"]==1)
{
<span class="fa fa-star checked"></span>
<span class="fa fa-star"></span>
<span class="fa fa-star"></span>
<span class="fa fa-star"></span>
<span class="fa fa-star"></span>
}
if($row["rating"]==2)
{
<span class="fa fa-star checked"></span>
<span class="fa fa-star checked"></span>
<span class="fa fa-star"></span>
<span class="fa fa-star"></span>
<span class="fa fa-star"></span>
}
</div>
</div>
';
}
}
else
{
$output = '<h3>No Data Found</h3>';
}
echo $output;
}
?>