Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/246.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 引导进度条问题_Php_Jquery_Html_Css_Twitter Bootstrap - Fatal编程技术网

Php 引导进度条问题

Php 引导进度条问题,php,jquery,html,css,twitter-bootstrap,Php,Jquery,Html,Css,Twitter Bootstrap,我只是在学习进度条和PHP数据库。到目前为止,我的进度条并没有增加它的价值。如果我手动将其设置为“2”,它将工作。如果我把它设置在2以上,它就不起作用了。这是通过Bootstrap完成的。这是我第一次访问这样的网站,如果我想说的没有意义,请原谅 <?php $items = $database->query("SELECT User_Items FROM Items WHERE Username = User_Here"); if($items->num_ro

我只是在学习进度条和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();
?>

项目总数


似乎是
$itemcount
的问题,
$itemcount
可能是空的

请参阅:它正在工作。

在siz变量中使用parseInt(),如下所示:

替换:

$(this).css('width', siz+'%');
与:

$(this).css('width', parseInt(siz)+'%');

它将“siz”变量值视为字符串,因此您需要将字符串更改为整数

我认为问题在于我从未使用过

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>

包括在内。

在我把它写进剧本后,它开始工作了(我想我已经有了它)。
感谢那些帮助过我的人

您调试过$itemcount了吗。它有什么价值吗?是的。它给出了一个值。你能澄清一下吗,你是说底部进度条(值硬编码为5)不起作用?或者它只是第一个变量值不起作用的,硬编码的一个不会像假设的那样“填满”。它是空的。变量也是如此。$itemcount正在打印一个值,比如说50。酒吧里的人不够多,最多5人。它是空的。