I'm trying to get the "class name" to return instead of the number that is associated with it.
I wrote a switch so that each of the 16 cases would be associated with what the class name is.
However, how do I make it output into my statement?
Here is what I have so far:
PHP Code:
function getClassByNumber($x){
switch($x){
case 1: return "Alchemist";
case 2: return "Assassin";
case 3: return "Dark Arts";
case 4: return "Dark Paladin";
case 5: return "Entertainer";
case 6: return "Hunter";
case 7: return "Mage";
case 8: return "Monk";
case 9: return "Paladin";
case 10: return "Pirate";
case 11: return "Priest";
case 12: return "Psion";
case 13: return "Scholar";
case 14: return "Thief";
case 15: return "Warlock";
case 16: return "Warrior";
}
}
$class = getClassByNumber($username->class);
echo You are now a $class.
Username is defined as seeking the table I want. Class is the field where the number is stored.
I have a table in my database (users) that contains a field (class) that is comprised of numbers. I want to convert those numbers to class names (warrior, mage, etc.) and have it print out what class name that person is, rather than just "You are a 1."
Warning: mysql_result() [function.mysql-result]: None not found in MySQL result index 615 in
Here is what I have.
PHP Code:
function getClassByNumber($x){
switch($x){
case 0: return "None";
case 1: return "Alchemist";
case 2: return "Assassin";
case 3: return "Dark Arts";
case 4: return "Dark Paladin";
case 5: return "Entertainer";
case 6: return "Hunter";
case 7: return "Mage";
case 8: return "Monk";
case 9: return "Paladin";
case 10: return "Pirate";
case 11: return "Priest";
case 12: return "Psion";
case 13: return "Scholar";
case 14: return "Thief";
case 15: return "Warlock";
case 16: return "Warrior";
}
}
$dString = "The $names $peepr known as $button<a href=main.php?username=$username&password=$password&action=look+at+$peeps[$i] $overlib>$thepeepname</a> is here$d<br>\n";