我创建了一个 css3 进度条。我想很好,所以如果用户有示例 3 喜欢/点,它说:14%,如果有 5,它说 29%(这只是一个例子)。
我对 if 和 else 很陌生,所以我认为我用错了。它下面的代码只显示“1 like”。
代码如下:
<?php
session_start();
$con=mysqli_connect("localhost","root","","facebook");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$username = $_SESSION['username'];
$result = mysqli_query($con,"SELECT likes FROM login where username='".$username."'");
while($row = mysqli_fetch_array($result))
if($row['likes'] > 0) { ?>
<div class="meter animate" align="left">
<span style="width: 14%"><span>1 likes </span></span>
</div>
<?php
} else if($row['likes'] > 1){ ?>
<div class="meter animate" align="left">
<span style="width: 28%"><span>2 likes </span></span>
</div>
<?php
}
mysqli_close($con);
?>