I have the following problem:
In an SMF Board ( Bulletin Board ) a MOD has been installed to display an "Experience Bar" for each user, which is based on the number of Posts.
The way this MOD should work is to calculate the number of posts and a percentage and a graphical display that he needs to reach the next level. For example: if the levels are 0-49, 50-99, 100-250, etc. and a user has 75 posts, the display should show 50% ( 25 / 50 ) That means: he has reached 50% resp. 25 posts of 50 until he reaches the next level ( 100 ). If one has 150 posts it should show 33,3% ( 50 / 150 ).
The actual settings in my Bulletin Board are:
-
0- 24
-
25- 50
-
51- 249
-
250- 499
-
500- 999
1000- 1499
1500- 1999
2000- 2499
2500- 3499
3500- >
Everything works absolutely fine up to 1000 posts. Then it displays incorrect values: example: if a user has 1287 posts it displays: 5.15% ( 1287 / 25 ) instead of: 57,4% ( 287 / 500 )
Because I have no knowledge of PHP at all, here is the function that should make it happen and which doesn't work correctly:
[FONT=courier new]//Bar of Experience Mod
function barExp()
{
global $txt, $db_prefix, $settings, $bar_posts, $bar_exps;
$bar_post = $bar_posts;
$bar_nextlevel = 50;
$bar_backlevel = 0;
$bar_newlevel = 50;
$check_req = db_query("
SELECT minPosts
FROM {$db_prefix}membergroups
ORDER BY minPosts ASC", __FILE__, __LINE__);
while($row_bar = mysql_fetch_array($check_req))
{
if ($bar_posts >= $row_bar['minPosts'])
$bar_backlevel = $row_bar['minPosts'];
}
$check_req = db_query("
SELECT minPosts
FROM {$db_prefix}membergroups
ORDER BY minPosts DESC", __FILE__, __LINE__);
while($row_bar = mysql_fetch_array($check_req))
{
if ($row_bar['minPosts'] > $bar_backlevel)
$bar_newlevel = $row_bar['minPosts'];
}
$bar_post -= $bar_backlevel;
$bar_nextlevel = $bar_newlevel - $bar_backlevel;
$bar_fill = 0;
$bar_exp = 0;
if ($bar_post > 0)
$bar_exp = round(sprintf(($bar_post / $bar_nextlevel) * 100),2);
$fill = (int) $bar_exp;
if ($fill)
$bar_fill = '<img src="' . $settings['images_url'] . '/bar_fill.gif" width="' . $fill . '" height="11">';
else
$bar_fill = '';
$bar_empty = 100 - $bar_exp;
if ($bar_empty)
$bar_empty = '<img src="' . $settings['images_url'] . '/bar_empty.gif" width="' . $bar_empty . '" height="11">';
else
$bar_empty = '';
if ($fill >= 100 || $fill < 1)
$bar_exps = '<img src="' . $settings['images_url'] . '/bar_up.gif" width="106" height="5"><br><img src="' . $settings['images_url'] . '/bar_full.gif" width="106" height="11"><br><img src="' . $settings['images_url'] . '/bar_down.gif" width="106" height="5"><br>'. $txt['bar_exp_completed'];
else
$bar_exps = '<img src="' . $settings['images_url'] . '/bar_up.gif" width="106" height="5"><br><img src="' . $settings['images_url'] . '/bar_left.gif" width="3" height="11">' . $bar_fill . '<img src="' . $settings['images_url'] . '/bar_right.gif" width="3" height="11">' . $bar_empty . '<br><img src="' . $settings['images_url'] . '/bar_down.gif" width="106" height="5"><br> ' . $txt['bar_exp_next'] . '<br> ' . $bar_exp . '% (' . $bar_post . '/' . $bar_nextlevel . ')';
}
[/FONT]
I hope you can help, as the owner of this MOD does not respond for weeks now.