我正在学习使用PHP制作进度条和数据库。目前为止,我的进度条没有增加其值。如果我手动将其设置为“2”,它会起作用,但是如果我将其设置为2以上的任何值,它就不起作用了。这是使用Bootstrap完成的。
这是我第一次在这样的网站上,如果我的话说不清楚,请见谅。
<?php
$items = $database->query("SELECT User_Items FROM Items WHERE Username = User_Here");
if($items->num_rows)
{
while($row = $items->fetch_assoc())
{
$itemcount = $row['User_Items'];
}
}
?>
<div class="row">
<div class="col-lg-2 col-md-4 col-sm-6">
<p>Total Items</p>
<div class="progress">
<div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="<?php echo $totalitems; ?>" aria-valuemin="0" aria-valuemax="5" style="width: 0%"></div>
</div>
<div class="progress">
<div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="2" aria-valuemin="0" aria-valuemax="5" style="width: 0%"></div>
</div>
<div class="progress">
<div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="5" aria-valuemin="0" aria-valuemax="5" style="width: 0%"></div>
</div>
</div>
</div>
<script type="application/javascript">
$('.progress-bar').each(function() {
var min = $(this).attr('aria-valuemin');
var max = $(this).attr('aria-valuemax');
var now = $(this).attr('aria-valuenow');
var siz = (now-min)*100/(max-min);
$(this).css('width', siz+'%');
});
</script>
<?php
mysqli_free_result($result);
$database->close();
?>
这张图片中进度条设置为“2”。
![enter image description here](https://istack.dev59.com/yaVX5.webp)
![enter image description here](https://istack.dev59.com/btdoe.webp)