I have a projectstatus in my mysql database. Depending on the status, it’s 1, 2 or 3. Also I have a css status bar of which I can set the width of, to see the progress.
Here’s the example code:
<td>" . $projstatid ."
<div class='meter-wrap'>
<div class='meter-value' style='background-color: #0a0; width: 33,3%;'>
<div class='meter-text'></div>
</div>
</div>
</td>
Now I can do 3 if statements at the width’s size like:
if ($projstatid) = 1 { echo "33.3%"; } elseif {..} else {...}
But how do I write a simple loop which loops through the numbers untill it reaches the $projstatid‘s value, but every time it re-loops adds 33.3%?
Even better would be if the loop devided the amount time of loopings by the max amount of projstatids. But that I’ll figure out, once I have this basic loop working.
EDIT
What I’m trying to do is to create a loop which does this:
x=1
y=0
$projectstatid = $record['projectstatid'] (in this example lets say it's 5)
loop: x=1, is it 5? Nope. return: y= +20%
loop: x=2, is it 5? Nope. return: y= +20%
etc.
untill it reaches 5 (and it will return 100%)
You can do something like this to compute the percent corresponding to your current value :
Here
$percentis the value to put in your css and$numberis your current status and$nbmaxis the maximum value that it could have.In your case your would have :
EDIT: Based on your edit I guess you want something like this: