PHP Code Example
The following is an example of how to get the data out with PHP
<?php function getHeroStats($heroName) { $database_host = "localhost"; $database_port = "3306"; $database_name = "HeroStats"; $database_username = "root"; $database_password = "root"; $database_stats_table_name = "HeroStats"; $database_mastered_class_table_name = "HeroStatsClasses"; mysql_connect($database_host . ":" . $database_port, $database_username, $database_password); mysql_select_db($database_name) or die(mysql_error()); $result = mysql_query("SELECT * FROM " . $database_stats_table_name . " WHERE LOWER(player_name) = '" . $heroName . "'") or die(mysql_error()); $row = mysql_fetch_array($result); $classes = array(); $result2 = mysql_query("SELECT * FROM " . $database_mastered_class_table_name . " WHERE hero_stats_id = " . $row["hero_stats_id"]) or die(mysql_error()); while ($row2 = mysql_fetch_array($result2)) { $c = array( "className" => $row2["class_name"], "level" => $row2["level"], "isMastered" => $row2["mastered"], ); array_push($classes, $c); } $heroInfo = array( "playerName" => $row["player_name"], "totalExp" => $row["total_exp"], "primaryClass" => $row["primary_class"], "primaryLevel" => $row["primary_level"], "secondaryClass" => $row["secondary_class"], "secondaryLevel" => $row["secondary_level"], "online" => $row["online"], "classes" => $classes, ); return $heroInfo; } ?>
when you call that function it returns an array with the info. Here is an example of how to print the info out:
<?php $heroInfo = getHeroStats("<USERNAME HERE>"); var_dump($heroInfo); ?>
Hi, I have put everything how to be and throws me to the php empty white box?