如何使用PHP更改Bootstrap进度条的值

时间:2016-11-23 07:45:59

标签: php html twitter-bootstrap twitter-bootstrap-3 progress-bar

如何使用PHP变量更改Bootstrap进度条的值? 到目前为止,这是我的代码:

 <?php                 
 $total_prize=360000;
 $paid_amount=160000;
 echo "
      <div class='progress'>
           <div class='progress-bar progress-bar-success' role='progressbar' aria-valuenow='$paid_amount' aria-valuemin='0' aria-valuemax='$total_prize' style='width:$paid_amount%;'>
            </div>
      </div>
 ";
 ?>

1 个答案:

答案 0 :(得分:2)

试试这个,

$total_prize=360000;
$paid_amount=260000;
$width = round(($paid_amount/$total_prize)*100,2);

echo '<div class="progress">
  <div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="'.$width.'"
  aria-valuemin="0" aria-valuemax="'.$total_prize.'" style="width:'.$width.'%">
    '.$width.'% Complete 
  </div>
</div>';