Thanks for opening this, even though I have a rather vague title.
Anyways, here's my predicament: I'm making a tool for players of the MMORPG RuneScape that would let them lookup their hiscores, and see how much XP they need from where they are to the next skill level.
Here's an example of what the hiscores look like. Here's that same page on my website. As you can see, the "XP to next level" isn't really...there.
Here's my coding:
Index.php
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/ TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en” lang=”en”>
<head>
<meta http-equiv=”content-type” content=”text/html; charset=iso-8859-1” />
<title>Look Up...</title>
</head>
<body>
<font size=+2><u>Look Up...</u></font><br>
<form action="action.php" method="get">
Username: <input name="username" type="text"/>
<input name="submit" type="submit" value="Look Up"/>
</form>
</body>
</html>
Action.php
<?php $username=$_REQUEST['username']; ?>
<html>
<head>
<title>Stats for <?php echo $username; ?></title>
</head>
<body>
<center>
<h1>Stats for <?php echo $username; ?></h1>
<a href="index.php">Return to Index</a>
<?php
function getCode ($user) {
$code = file_get_contents('http://hiscore.runescape.com/hiscorepersonal.ws?user1='.$user);
$start = strpos($code,"Minigames");
$code = substr($code,0,$start);
$start = strpos($code,'<table class="table_back" style="margin-bottom:5px" id="mini_player">');
$code = substr($code,$start);
$start = strpos($code,'<br style="clear:both" />');
$code = substr($code,0,$start);
$string = $code;
$patterns[0] = '/class=".*"/';
$patterns[1] = '/align="center"/';
$patterns[2] = '/<a.*">/';
$patterns[3] = '/<\/a>/';
$patterns[4] = '/<img >/';
$replacements[0] = '';
$replacements[1] = '';
$replacements[2] = '';
$replacements[3] = '';
$replacements[4] = '';
$code = preg_replace($patterns, $replacements, $string);
$code = str_replace("\n",'',$code);
$code = str_replace(" ",'',$code);
$code = str_replace("</tr>","</tr>\n",$code);
$code = str_replace("<tr>","\n<tr>",$code);
$pattern = '|<tr><td></td><td>(.*)</td><td>(.*)</td><td>(.*)</td><td>(.*)</td></tr>|';
preg_match_all($pattern,$code,$arr);
return $arr;
}
$array = getCode($username);
$value = '-';
echo '<table border="1" width="50%" length="100%"><tr><th>Skill</th><th>Rank</th><th>Level</th><th>XP</th><th>XP to Next Level</th><tr>';
for($i=0; $i<count($array[1]); $i++) {
echo '<text align="center"><tr><td>'.$array[1][$i].'</td><td>'.$array[2][$i].'</td><td>'.$array[3][$i].'</td><td>'.$array[4][$i].'</td><td>'.$value.'</td></tr></text>';
}
echo '</table>';
?>
</center>
</body>
</html>
I'm completely stuck, though. Here's a list of the Skill Levels and their corresponding XP point values. Again, here's the site in action.
If anyone could point me in the right direction, or give any constructive input, I'd greatly appreciate it.