Jump to content

Recommended Posts

Hello,

So heres my problem:

im trying to create a level system, so that when people do something on the site they gain XP,

each level is set out in the database as such:

_______

|xp | lvl |

| --- |---|

|100| 1 |

|150| 2 |

|300| 3 |

|450| 4 |

|700| 5 |

etc etc...

 

So that if you have that amount of xp or greater, then your that lvl (I.E i have 160 xp im lvl 2)

 

Now, im trying to create a bar underneath it to show the percentage you have completed

I.E. you have 25 xp the bar needs to show 25% of the bar full

 

ive managed to get it to show the ammount of xp you need untill the next level, but im not sure how to convert that into a percentage and add it to the bar.

 

Can someone help me with this please.

 

Thanks

Rich

Link to comment
https://forums.phpfreaks.com/topic/184483-need-some-complicated-php-help-please/
Share on other sites

Remember,  you need to workout the XP required to level up, for example, if you have these values

Level 1

$maxexp = 100

 

Level 2

$maxexp = 150

 

then when you start level 2 it will save 66%, because your XP would be on 100 of 150, (hence 66%)

So you will need to get the differences between your current level and the next,

 

So $currentexp should be $currentexp - $previouslevelMaxXP

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.