Jump to content

Need some complicated PHP help please.


richarro1234

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.