不会回显四舍五入的数字


Won't echo a rounded number

出于某种原因,我的代码仅在最后一页等于 3 时才有效。如果它等于 2,它将给出这样的图像http://gyazo.com/7a590068ec0e4a6ba4da586c60f36658

如果它是 = 3,它将给出正确的方式,如下所示http://gyazo.com/7188af3281d0964e085b86d8449e80c6

这是代码!

<?php
$result3 = mysql_query("SELECT * FROM html where id='$userid'");
while($row3 = mysql_fetch_array($result3))
{ 
$lastpage=$row3['lastpage'];
}
$htmltotal = 12;
$res = floor(($lastpage / $htmltotal) * 100);
?>

现在,如果 lastpage 等于 2,它应该给出 17,因为 16.6777776777 四舍五入为 17。相反,它不显示任何内容。但是,如果它不必像 3 那样四舍五入,等于正好 25,那么它确实会显示。有什么想法吗?

Javascript:

$('.about-menu').on('click',function(){
    // progress bar animation
    $('.progress .bar').each(function () {
      var me = $(this),
          datascore = me.attr('data-score'),
          score = $(this).find('.title-score');

          me.animate({
              width: datascore + '%',
              easing: 'swing'
          }, 100),  
          $(score).animateNumbers(datascore, true, 1500);
    });

出于某种原因,任何不是 5 倍的数字都不会加载。

使用 ceil() 而不是 floor(

),你的要求是 ceil() 并且你使用的是 floor()塞伊尔 :->如有必要,通过向上舍入值返回下一个最高整数值。

$result3 = mysql_query("SELECT * FROM html where id='$userid'");
while($row3 = mysql_fetch_array($result3))
{ 
$lastpage=$row3['lastpage'];
}
$htmltotal = 12;
$res = ceil(($lastpage / $htmltotal) * 100); 

round() 同时用作 ceil 和地板函数