Are you first timer at Why not join us and start exchange your programming knowledge with everyone. Register today!

PHP - progress bar based on variable

0 votes
added Jul 20, 2018 in PHP by LC Marshal Captain (26,090 points)
  $topay = $unit->field_cost_to_own->value();

  $balanceAmt =  $unit->field_cto_balance->value();
  $paidAmt = $topay - $balanceAmt;
  $percent_own = $paidAmt / $topay * 100;

  // echo '<pre>';
  // print_r($percent_own);
  // exit;

<div class="progress-bar-wrapper">
  <div class="inner" style="width: <?php print $percent_own; ?>%"><?php print $percent_own; ?>% paid</div>

.progress-bar-wrapper {
  width: 280px;
  margin: 0 auto 20px;
  display: block;
  border: 1px solid #eee;
  .inner {
    background: $color-green;
    display: block;
    height: 10px;


Please log in or register to response this reference. - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.