 |
<%
' this code opens the database
myDSN="DSN=renegades"
set conntemp=server.createobject("adodb.connection")
conntemp.open myDSN
' this code retrieves the data
mySQL3="select count(gamenum) as gn from scores"
set rsscorescount=conntemp.execute(mySQL3)
' this code detects if data is empty
If rsscorescount.eof then
response.write "No records matched "
response.write mySQL & " So cannot make table..."
connection.close
set connection=nothing
response.end
end if
g_n = rsscorescount("gn")
game_num=request.querystring("gamenum")
if game_num = "" then
game_num = g_n
end if
' this code retrieves the data
mySQL="select * from scores where gamenum= " & game_num & ""
set rsscores=conntemp.execute(mySQL)
' this code detects if data is empty
If rsscores.eof then
response.write "No records matched "
response.write mySQL & " So cannot make table..."
connection.close
set connection=nothing
response.end
end if
' this code retrieves the data
mySQL2="select * from box_scores where game_number= " & game_num & " order by batting_order"
set rstemp=conntemp.execute(mySQL2)
' this code detects if data is empty
If rstemp.eof then
response.write "No records matched "
response.write mySQL & " So cannot make table..."
connection.close
set connection=nothing
response.end
end if
Dim inn(7)
Dim oppinn(7)
' put fields into variables
rh = rsscores("renhome")
opp=rsscores("opponent")
ren_score=rsscores("renscore")
opp_score=rsscores("oppscore")
inn(0)=rsscores("first")
inn(1)=rsscores("second")
inn(2)=rsscores("third")
inn(3)=rsscores("fourth")
inn(4)=rsscores("fifth")
inn(5)=rsscores("sixth")
inn(6)=rsscores("seventh")
oppinn(0)=rsscores("oppfirst")
oppinn(1)=rsscores("oppsecond")
oppinn(2)=rsscores("oppthird")
oppinn(3)=rsscores("oppfourth")
oppinn(4)=rsscores("oppfifth")
oppinn(5)=rsscores("oppsixth")
oppinn(6)=rsscores("oppseventh")
innflag = 0
oppinnflag = 0
For x = 0 to 6
if inn(x) <> "" AND innflag = 0 then
totscore = totscore + inn(x)
lastinn = x + 1
else
innflag = 1
end if
if oppinn(x) <> "" AND oppinnflag = 0 then
opptotscore = opptotscore + oppinn(x)
opplastinn = x + 1
else
oppinnflag = 1
end if
next
' write the fields to browser
cellstart=" | "
response.write ""
response.write ""
for y = 1 to g_n
response.write "| Game " & y & " Boxscore | "
if y = 5 and g_n > 9 then
response.write " "
end if
next
response.write " "
response.write " "
response.write " Game " & game_num & " Results "
response.write ""
'response.write "" & totscore & " Renegades " & opp_score & " " & opp & " | "
response.write ""
if lastinn > opplastinn then
innvar = lastinn
else
if opplastinn = NULL then
innvar = lastinn
else
innvar = opplastinn
end if
end if
response.write " | "
for i = 1 to innvar
if i = 1 then
suff = "st"
end if
if i=2 then
suff = "nd"
end if
if i=3 then
suff = "rd"
end if
if i=4 or i=5 or i=6 or i=7 then
suff = "th"
end if
response.write "" & i & suff & " | "
next
response.write "Final | "
response.write " "
if rh = "True" then
response.write "| " & opp & " | "
for i = 0 to opplastinn-1
response.write "" & oppinn(i) & " | "
next
response.write "" & opptotscore & " | "
response.write " "
response.write "| Renegades | "
for i = 0 to lastinn-1
response.write "" & inn(i) & " | "
next
if lastinn <> opplastinn then
response.write "x | "
end if
response.write "" & totscore & " | "
else
response.write "Renegades | "
for i = 0 to lastinn-1
response.write "" & inn(i) & " | "
next
response.write "" & totscore & " | "
response.write " "
response.write "| " & opp & " | "
for i = 0 to opplastinn-1
response.write "" & oppinn(i) & " | "
next
if lastinn <> opplastinn then
response.write "x | "
end if
response.write "" & opptotscore & " | "
end if
response.write " "
response.write " "
response.write " | "
response.write " "
%>
| Player |
Avg |
AB |
H |
R |
RBI |
HR |
3B |
2B |
<%
' Now lets grab all the records
DO UNTIL rstemp.eof
' put fields into variables
player_name=rstemp("player_name")
gender=rstemp("gender")
game_number=rstemp("game_number")
batting_order=rstemp("batting_order")
ab=rstemp("ab")
h=rstemp("h")
r=rstemp("r")
rbi=rstemp("rbi")
hr=rstemp("hr")
triples=rstemp("triples")
doubles=rstemp("doubles")
totab = ab + totab
toth = h + toth
totr = r + totr
totrbi = rbi + totrbi
tothr = hr + tothr
tottriples = triples + tottriples
totdoubles = doubles + totdoubles
if ab <> 0 then
avg=(h/ab)
' write the fields to browser
cellstart=""
response.write " | "
response.write "| " & player_name & " | "
response.write cellstart & formatnumber(avg,3,0) & ""
response.write cellstart & ab & ""
response.write cellstart & h & ""
response.write cellstart & r & ""
response.write cellstart & rbi & ""
response.write cellstart & hr & ""
response.write cellstart & triples & ""
response.write cellstart & doubles & ""
response.write " "
end if
rstemp.movenext
LOOP
totavg=(toth/totab)
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 " "
%>
<%
' Now close and dispose of resources
rsscores.close
set rsscores=nothing
rsscorescount.close
set rsscorescount=nothing
rstemp.close
set rstemp=nothing
conntemp.close
set conntemp=nothing
%>
|
 |