Q: Calculation to find Level If I know the value of $c_xp, how can I find $c_level without writing 100's of if statements.
Level     XP
1         0-99
2         100
3         500  +400 xp points from last level
4         1000 +500 xp points from last level
5         1600 +600 xp points from last level
6         2300 +700 xp points from last level
7         3100 +800 xp points from last level
8         4000 +900 xp points from last level

And so on.
$c_level = ;


A: If I understand your pattern correctly:
$c_level = floor((-1 + sqrt(1 + 4 * ($c_xp + 500) / 100 * 2)) / 2) - 1;

You are adding 100, then 400, then 500, 600, 700, 800, and so on. Because 100 kind of breaks the pattern, we are going to ignore it for now.
Assuming you were going after the pattern
Level     XP

1         0-99
2         100-299
3         300-599
4         600-999
5         1000-1499
6         1500-2099

This would be easier, because the increments are 100, 200, 300, and so on. Anything under 100 would be level 1. Anything under 300 would be level 2. Anything under 600 would be level 3. Conveniently:
0+1=1 (hence 100)
0+1+2=3 (hence 300)
0+1+2+3=6 (hence 600)

and so on and so fourth. The sum of the first x integers is 0.5 * x * (1 + x) = y, where y is the sum - see http://en.wikipedia.org/wiki/Summation.
In our case, we have 100 times the sum. We can simply divide our XP by 100 to get y, and use the quadratic formula to solve for x. In the case if XP is 600, the level is 4. 
600 / 100 = 6, and 0.5 * x * (1 + x) = 6. The quadratic formula tells us x is 3. We have to use floor() on it and add 1 for reasons I cannot explain. Long story short to adjust with the lack of patter under 500 points, we add 500 and subject 2 to the final amount for the formula to work.  

A: *

*Store level-xp pairs in array:
$levels = array(
    1 => 99,
    2 => 499,
    3 => 999
);

Note that the value associated with level is the maximum value for given level, i.e. one more point would be associated with next level.

*Loop through levels array, and check whether player's XP is less than level max value:
$level = null;
$xp = 845;

foreach ($levels as $l => $max) {
    if ($xp <= $max) {
        $level = $l;
        break;
    }
}


A: Try this:
<?php
    $levels=Array(
    1=>99,
    2=>100,
    3=>500,
    4=>1000,
    5=>1600,
    6=>2300,
    7=>3100,
    8=>4000
    );

    //this will probably be pulled from somewhere else,
    //take it out:
    $c_xp=499;
    foreach($levels as $level=>$xp) {
        if($c_xp>=$xp) $c_level=$level;
        else break;
    }
    echo $c_level;

?>


A: Try this
$maxLevel = 10;
$exp[2] = 100;

if($c_xp < 100)
    $c_level = 1;
elseif($c_xp < 500)
    $c_level = 2;

else
{   
   $increment = 400;

   for($i = 3; $i<= $maxLevel; $i++)
    {

        $prevExp = $exp[$i-1];
        $calc = $increment + $prevExp;
        if($c_xp == $calc)
        {
            $c_level = $i;
            break;
        }
        elseif($c_xp > $prevExp && $c_xp < $calc)
        {
            $c_level = $i-1;
            break;
        }
        $exp[$i] = $calc;
        $increment += 100;
    }
}

$c_level = isset($c_level) ? $c_level : $maxLevel;
echo "level $c_level";

Switch the maxLevel var to what you want max level to be.
Probably a more efficient solution, but I suck with algorithms , and it is the weekend.
