我已经创建了基于职位的级别系统。获取每个级别的百分比
Level 1 = 1-25 posts
Level 2 = 26-50 posts
Level 3 = 51-250 posts, etc...
我也想显示一个进度条
通常你会这么像这样:
$author_posts = 15;
$progress = ($author_posts * 100)/25; //(level 1)
的进度百分比是那么60%
。
但是,如果用户已达到level 3
,应该如何使用?
if($author_posts >= '250') {
$progress = '100';
} elseif($author_posts < '51') {
$progress = '0';
} else {
$progress = // what should I use here?
}
<div class="progress-bar" style="width:<?php echo esc_attr($progress); ?>%;"></div>
你能澄清你的百分比是什么意思?是百分比直到下一个级别? –
basic math =($ author_posts/250)* 100 – nogad
它是当前级别(level3)内的百分比。或者等到3级被清除后,完成多少比例。我认为它应该是这样的,但我不知道:'$ progress($ author_posts * 100)/(250 - 51);' – kiarashi