Made PHP CSS and HTML progress bar


I made a progress bar with PHP, CSS, and HTML. Well it works correctly but for instance a user has 6/6 stamina. The bar is going to be 6% of 100%. How would I change this? Here's the coding below..

<div class="progress-outer">
    <div class="progress-inner"
    style="width: <?php echo $energy ?>%;">Energy:<?php echo $energy . '/' . $max_energy ?></div>

The CSS is..

.progress-outer {
background: #000000;
height: 20px;
padding: 2px;
border: 1px solid #FFFFFF;

.progress-inner {
font-size: 16px;
color: #FFFFFF;
font-weight: bold;
background: #333333;
height: 100%;

The first <?php echo $energy ?> should be <?php echo ($energy/$max_energy*100) ?>...