PDA

View Full Version : Retriving and Displaying Info ?


Charles.pilot
08-11-2008, 11:13 AM
Hello

My son has been working on a website for some months now, he actualy seams to be quite good at it, just like all farthers i have the dad complex and like to make him think i know what im doing...

Hes been having problems with this for a week or two and i would love to be able to tell him the solution *Dad Complex*

The problem is he wants a page where him and his friends can enter thair usernames in to a box and click submit, this should then take them to another page displaying the users highscores for a game called runescape in a table. when you go to

hiscore.runescape.com/index_lite.ws?player=YourUsername

Replacing "YourUsername" with a real username this will provide you with a string of numbers organised into groups. The numbers at the front are grouped in threes, and are your rank, level and experience in each skill. So he wants it as you click submit in a box you are presented with your hiscores formatted in a table. i belive this is the string of numbers that is produced by going to the above link with my sons username

376823,1328,9743276 640826,71,861411 461740,71,856781 843944,71,852856 740331,71,884067 1352971,51,122901 667480,49,99638 949848,60,290068 1483844,53,149319 159111,83,2701879 655536,61,316422 273210,73,1011869 300000,64,418762 800324,51,115963 1213969,47,76701 717461,62,362519 545131,35,24350 731594,40,37566 730579,45,62766 488096,43,52724 368055,34,20909 436044,42,47304 255171,53,139374 107166,55,182154 131619,43,54973 -1,-1 -1,-1 -1,-1 -1,-1

ps: his username is 566666824486

any help would be great as im rubbish at this stuff, and i know im asking a lot but could somone maby post a basic working "prototype" and a small explination on how this is done ?

Charles

Charles.pilot
08-11-2008, 01:49 PM
Ok so this is what i have so far.....

<!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">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<title>Untitled 2</title>
</head>

<body text="#808080" bgcolor="#151616" link="#808080" vlink="#808080" alink="#808080">
<p align="center"><font face="Arial" size="2"><br />
</font>
<form method="post" action="">
<p align="center"><font face="Arial"><font size="2">User Name: </font> <input name="Text1" type="text" /><font size="2">
<br />
<br />
</font>
<input name="Submit1" type="submit" value="submit" /></font></p>
</form>

</p>
<font face="Arial" size="2">
<%
If Request.form("Text1") <> "" Then
Response.Buffer = True
Dim objXMLHTTP, xml

' Create an xmlhttp object:
Set xml = Server.CreateObject("Microsoft.XMLHTTP")
' Or, for version 3.0 of XMLHTTP, use:
' Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP")

' Opens the connection to the remote server.
xml.Open "GET", "http://hiscore.runescape.com/index_lite.ws?player=" & request.Form("Text1") , False

' Actually Sends the request and returns the data:
xml.Send

tst = Replace(xml.responsetext, chr(10), "</td></tr><tr><td width=""100px"">")
tst = replace(tst, ",", "</td><td width=""100px"">")
Response.Write "<table><tr><td width=""100px"">" & tst & "</td></tr></table>"


Set xml = Nothing
End if
%>
</font>
</body>

</html>


I seam to have this working but now i need to get it to centerize the output table and lable each colum and each row, this is where i am struggling. i also need the script to automaticly change -1 outputs to "Not Ranked", here is what the colums and rows should be called:

Colums are:
Rank Level XP


Rows Are:
Overall
Attack
Defence
Strength
Hitpoints
Ranged
Prayer
Magic
Cooking
Woodcutting
Fletching
Fishing
Firemaking
Crafting
Smithing
Mining
Herblore
Agility
Thieving
Slayer
Farming
Runecraft
Hunter
Construction
Summoning
Duel Tournament
Bounty Hunters
Bounty Hunter Rogues
Fist of Guthix

Any help would be great.

charles

Spudhead
08-11-2008, 02:50 PM
It's generally frowned upon to give out whole chunks of code, but screw it, I was bored and this seemed like fun :D

Here's what I have. I've taken a slightly different approach, I think it's a bit easier to follow the logic if you split the string into an array and loop through it. But that's just personal preference.

The other thing is that I'm assuming the data fields come back in exactly the same order you've listed them. If they don't, you're going to need some way of matching them up.

But anyway. This seems to work:

<%
If Request.form("Text1") <> "" Then

'strUserName = 566666824486
strUserName = request.Form("Text1")

aryCategories = split("Overall,Attack,Defence,Strength,Hitpoints,Ranged,Prayer,Magic,Cooking,Woodcutting,Fletching,Fishing, Firemaking,Crafting,Smithing,Mining,Herblore,Agility,Thieving,Slayer,Farming,Runecraft,Hunter,Constr uction,Summoning,Duel Tournament,Bounty Hunters,Bounty Hunter Rogues,Fist of Guthix", ",")

dim objXMLHTTP, strURL, strScores
strURL = "http://hiscore.runescape.com/index_lite.ws?player=" & strUserName
set objXMLHTTP = Server.CreateObject("Microsoft.xmlhttp")
objXMLHTTP.open "GET", strURL, false
objXMLHTTP.send
strScores = objXMLHTTP.responseText

if strScores <> "" then

aryScores = split(strScores, chr(10))

response.write("<div align=""center"">" & vbCrLf)
response.write("<table>" & vbCrLf)
response.write("<tr><th>Category</th><th>Rank</th><th>Level</th><th>Experience</th></tr>" & vbCrLf)

for i = 0 to uBound(aryScores)-1

strScore = aryScores(i)

if inStr(strScore, "-1") < 1 then

aryScore = split(strScore, ",")
strRank = aryScore(0)
strLevel = aryScore(1)
strExperience = aryScore(2)
response.write("<tr><td>" & aryCategories(i) & "</th><td>" & strRank & "</td><td>" & strLevel & "</td><td>" & strExperience & "</td></tr>" & vbCrLf)

else

response.write("<tr><td>" & aryCategories(i) & "</th><td colspan=""3"">Not Ranked</td></tr>" & vbCrLf)

end if

next

response.write("</table>" & vbCrLf)
response.write("</div>" & vbCrLf)

end if

end if

%>

Charles.pilot
08-11-2008, 03:05 PM
This seams to work briliantly although when you enter a username who is ranked on the last four skils you recive


Microsoft VBScript runtime error '800a0009'
Subscript out of range: '[number: 2]'

/s.asp, line 54

for instance try entering this name "Markoman94" and look at the outoput, oh and if i wanted to be realy anoying i could ask that the catogry names are not "centerised" they should read normaly "left aligned" other than that your brilliant !

ps. i realy realy do apriciate the help =D

charles

Charles.pilot
08-11-2008, 03:12 PM
Or maby insted of "not Ranked" it could just replace the "-1" with a "0" or "N/A" in each colum, this would be more visualy apealing and probably work better to?

Charles.pilot
08-11-2008, 04:43 PM
I have found a simple solution to all of the above problems. thanks for all the help!

charles