Page 2 of 2

Re: Displaying echo Outside PHP Script

Posted: Thu Jun 24, 2010 7:54 pm
by AbraCadaver
At its simplest you would have images named just like the skill except with an extension like .gif or whatever, so 'Attack.gif'. Then you can just echo an img tag with the src set to $parts[0].'.gif'

Re: Displaying echo Outside PHP Script

Posted: Fri Jun 25, 2010 5:27 pm
by jonathantheaker
Thanks for that its worked a treat!

Finnished and working Code:

Code: Select all

<?php

$user = $_GET['user'];
$lines = file('http://hiscore.runescape.com/index_lite.ws?player=' . $user, FILE_IGNORE_NEW_LINES);

$skills = array('Overall', 'Attack', 'Defence', 'Strength', 'Constitution', 'Ranged', 'Prayer', 'Magic', 'Cooking', 'Woodcutting', 'Fletching', 'Fishing', 'Firemaking', 'Crafting', 'Smithing', 'Mining', 'Herblore', 'Agility', 'Thieving', 'Slayer', 'Farming', 'Runecrafting', 'Hunter', 'Construction', 'Summoning', 'Dungeoneering');

$activities = array('Duel Tournament', 'Bounty Hunters', 'Bounty Hunter Rogues', 'Fist of Guthix', 'Mobilising Armies', 'B.A Attackers', 'B.A Defenders', 'B.A Collectors', 'B.A Healers', 'Castle Wars Games');

        echo '<table class="tablemain">'
                        .'<tr>'
                        .'<td class="mainheadercell" colspan="4">Skill Hiscores - ' . $user . ' </td>'
                        .'</tr>'
                        .'<tr>'
                        .'<td class="headercells">Skill</td>'
                        .'<td class="headercells">Rank</td>'
                        .'<td class="headercells">Level</td>'
                        .'<td class="headercells">Xp</td>'
                        .'</tr>';

$i = 0;
foreach($skills as $skill) {
        $parts = explode(',', $lines[$i]);
		$parts = array_map('number_format',  $parts);
		$parts = str_replace('-1', '--', $parts);
        echo '<tr>'
                        .'<td class="cellmain"><img border="0" src="' . strtolower($skill) . '.gif"><br>' . $skill . '</td>'
                        .'<td class="cellmain">' . $parts[0] . '</td>'
                        .'<td class="cellmain">' . $parts[1] . '</td>'
                        .'<td class="cellmain">' . $parts[2] . '</td>'
                        .'</tr>';
        $i++;
}
        echo '</table><br>';

        echo '<table class="tablemain">'
                        .'<tr>'
                        .'<td class="mainheadercell" colspan="3">Activity Hiscores - ' . $user . ' </td>'
                        .'</tr>'
                        .'<tr>'
                        .'<td class="headercells">Game</td>'
                        .'<td class="headercells">Rank</td>'
                        .'<td class="headercells">Score</td>'
                        .'</tr>';
                        
foreach($activities as $activity) {
        $parts = explode(',', $lines[$i]);
		$parts = array_map('number_format',  $parts);
		$parts = str_replace('-1', '--', $parts);
        echo '<tr>'
                        .'<td class="cellmain"><img border="0" src="' . strtolower($activity) . '.gif"><br>' . $activity . '</td>'
                        .'<td class="cellmain">' . $parts[0] . '</td>'
                        .'<td class="cellmain">' . $parts[1] . '</td>'
                        .'</tr>';
        $i++;
}
        echo '</table><br>';
?>
URL to working script (Use username HSA Jay if testing): http://services.hintscape.net/highscores/

So id lke to say a huge thank you to AbraCadaver for all of his help. I hope someone else may be able to make use of this code or parts of it.

Thanks again!