Experience Level Evaluation Programming Tutorial
Learn to use PHP to tally up user Experience Level from any number stored or derived from a MySQL database, and render graphics and amounts accordingly. Can be used for games or web site programming. You can easily adjust all numbers to fit your system level ascension scale.
<?php
// Connect to your database like you normally do, then get any value into the $count variable
$username = "Jeremy";
$count = 287;
$lvl = 1;
if ($count >= 12800) { $lvl = 10; }
else if ($count >= 6400) { $lvl = 9; }
else if ($count >= 3200) { $lvl = 8; }
else if ($count >= 1600) { $lvl = 7; }
else if ($count >= 800) { $lvl = 6; }
else if ($count >= 400) { $lvl = 5; }
else if ($count >= 200) { $lvl = 4; }
else if ($count >= 100) { $lvl = 3; }
else if ($count >= 50) { $lvl = 2; }
// Render stars or any graphics/images according to dynamic $lvl number
$stars = "";
$i = 1;
while ($i <= $lvl) {
$stars .= "★";
$i++;
}
echo "$stars<br />$username is level $lvl with $count experience points";
?>