 |
<%
' this code opens the database
myDSN="DSN=renegades"
set conntemp=server.createobject("adodb.connection")
conntemp.open myDSN
Dim player_name(23)
Dim ab(23)
Dim h(23)
Dim r(23)
Dim rbi(23)
Dim hr(23)
Dim triples(23)
Dim doubles(23)
Dim avg(23)
Dim game_num(23)
Dim sorttmp(23)
name_var=request.querystring("name")
mySQL2="select distinct player_name from box_scores"
set rstemp2=conntemp.execute(mySQL2)
' this code detects if data is empty
If rstemp2.eof then
response.write "No records matched "
response.write mySQL2 & " So cannot make table..."
rstemp2.close
set rstemp2=nothing
response.end
end if
cellstart=" | "
response.write "| Individual Player Stats | "
response.write "Choose a player | "
DO UNTIL rstemp2.eof
response.write ""
x=1
xflag=0
DO UNTIL xflag = 99
playername=rstemp2("player_name")
response.write cellstart & "" & playername & ""
rstemp2.movenext
if rstemp2.eof Or x=7 then
xflag=99
end if
x=x+1
LOOP
response.write " "
LOOP
response.write "|   | "
response.write " "
if name_var <> "" then
mySQL="select player_name,game_number,ab,h,r,rbi,hr,triples,doubles from box_scores where player_name = " & "'" & name_var & "'" & " ORDER BY game_number"
set rstemp=conntemp.execute(mySQL)
' this code detects if data is empty
If rstemp.eof then
response.write "No records matched "
response.write mySQL & " So cannot make table..."
rstemp.close
set rstemp=nothing
response.end
end if
DO UNTIL rstemp.eof
player_name(indstat)=rstemp("player_name")
game_num(indstat)=rstemp("game_number")
ab(indstat)=rstemp("ab")
h(indstat)=rstemp("h")
r(indstat)=rstemp("r")
rbi(indstat)=rstemp("rbi")
hr(indstat)=rstemp("hr")
triples(indstat)=rstemp("triples")
doubles(indstat)=rstemp("doubles")
'avg(indstat)=rstemp("avg")
totab = totab + ab(indstat)
toth = toth + h(indstat)
totr = totr + r(indstat)
totrbi = totrbi + rbi(indstat)
tothr = tothr + hr(indstat)
tottriples = tottriples + triples(indstat)
totdoubles = totdoubles + doubles(indstat)
rstemp.movenext
indstat = indstat + 1
LOOP
totavg = toth/totab
response.write""
response.write""
response.write"Individual Stats for " & name_var & " | "
response.write"| Click game number for box score | "
response.write""
response.write"| Game | "
response.write"Avg | "
response.write"AB | "
response.write"H | "
response.write"R | "
response.write"RBI | "
response.write"HR | "
response.write"3B | "
response.write"2B | "
response.write" "
For x = 0 to indstat-1
if ab(x) <> 0 then
avg(x) = (h(x)/ab(x))
' write the fields to browser
cellstart=""
response.write " | "
response.write "| " & game_num(x) & " | "
response.write cellstart & formatnumber(avg(x),3,0) & ""
response.write cellstart & ab(x) & ""
response.write cellstart & h(x) & ""
response.write cellstart & r(x) & ""
response.write cellstart & rbi(x) & ""
response.write cellstart & hr(x) & ""
response.write cellstart & triples(x) & ""
response.write cellstart & doubles(x) & ""
response.write " "
end if
next
cellstart=""
response.write " | "
response.write "| Totals | "
response.write cellstart & formatnumber(totavg,3,0) & ""
response.write cellstart & totab & ""
response.write cellstart & toth & ""
response.write cellstart & totr & ""
response.write cellstart & totrbi & ""
response.write cellstart & tothr & ""
response.write cellstart & tottriples & ""
response.write cellstart & totdoubles & ""
response.write " "
response.write " "
end if
if name_var <> "" then
' Now close and dispose of resources
rstemp.close
set rstemp=nothing
conntemp.close
set conntemp=nothing
end if
%>
|
 |