我只是学习进度条和
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”
此图像的进度条设置为“5”,即最大值.
最佳答案 它似乎是$itemcount的问题,$itemcount可能是空的.
见:JsFiddle它正在工作.