根据用户的评分,来渲染星星。
①从数据库取出score
②?
for($i=0;$i<$star;$i++){ ????????$str .='<i class="fas fa-star"></i>'; }
<?php
$sql="SELECT * FROM land_review LEFT JOIN user_form ON land_review.userid = user_form.userid WHERE landid ={$id}";
$row=mysqli_query($link,$sql);
while($res = mysqli_fetch_assoc($row))
{
$star=$res['score'];
$str="";
for($i=0;$i<$star;$i++){
$str .='<i class="fas fa-star"></i>';
}
echo '<div class="pingjia">
<div class="stars">'.$str.'</div>
<div class="sentence">
<p>'.$res['review'].'</p>
</div>
<div class="user">
<img src="'.$res['portrait'].'" alt="">
<div class="user-info">
<h3>'.$res['username'].'</h3>
<span>'.$res['briefinfo'].'</span>
</div>
</div>
<span class="fas fa-quote-right"></span>
</div>';
}
?>
?
|