Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-09-2012, 10:21 PM   PM User | #1
Hydrian
New Coder

 
Join Date: Aug 2012
Posts: 40
Thanks: 5
Thanked 0 Times in 0 Posts
Hydrian is an unknown quantity at this point
Add XP on button click

Hi, ive been working on a leveling system for my class, but im at the point where i need to make it automatic, so when a button is clicked add 5xp to the total xp.

Here is my code for the system
PHP Code:
<?php
$array 
= array(
    array(
        
'xp_required' => 150,
        
'level' => 1
    
),
    array(
        
'xp_required' => 225,
        
'level' => 2
    
),
    array(
        
'xp_required' => 337,
        
'level' => 3
    
),
    array(
        
'xp_required' => 566,
        
'level' => 4
    
),
    array(
        
'xp_required' => 846,
        
'level' => 5
    
),
    array(
        
'xp_required' => 1274,
        
'level' => 6
    
),
    array(
        
'xp_required' => 1911,
        
'level' => 7
    
),
    array(
        
'xp_required' => 2866,
        
'level' => 8
    
),
    array(
        
'xp_required' => 4299,
        
'level' => 9
    
),
    array(
        
'xp_required' => 6449,
        
'level' => 10
    
)
);
$current_xp 155;
foreach( 
$array as $reqs ){
    if( 
$current_xp $reqs['xp_required'] ){
        
$level $reqs['level'];
    }
}
echo 
'You are at ' ,$level;

?>
http://pastebin.com/vTriKTkG

Please tell me how to do this.

Last edited by Hydrian; 11-10-2012 at 12:14 AM..
Hydrian is offline   Reply With Quote
Old 11-09-2012, 11:30 PM   PM User | #2
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,687
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
You really want me to dig through your entire code base without any idea of where I should be looking? You'll need my hourly consulting rate...

Perhaps you could paste the relevant portion of code into your post, we might have a recommendation on what changes you might need to make.

As it is, your question smells like lazy wantin' free work.
__________________
Fumigator is offline   Reply With Quote
Old 11-10-2012, 12:15 AM   PM User | #3
Hydrian
New Coder

 
Join Date: Aug 2012
Posts: 40
Thanks: 5
Thanked 0 Times in 0 Posts
Hydrian is an unknown quantity at this point
Quote:
Originally Posted by Fumigator View Post
You really want me to dig through your entire code base without any idea of where I should be looking? You'll need my hourly consulting rate...

Perhaps you could paste the relevant portion of code into your post, we might have a recommendation on what changes you might need to make.

As it is, your question smells like lazy wantin' free work.
There that should do it, my question is that im not sure on what to do.
Hydrian is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:59 AM.


Advertisement
Log in to turn off these ads.