%if session("username") = "" then
response.Redirect("login.asp")
End if
set r=Server.CreateObject("ADODB.RECORDSET")
r.open "select * from stock where ipo=true",conn,3,2
while not r.eof
set rr = Server.CreateObject("adodb.recordset")
rr.open "select sum(purchaseprice) as sumofpurchase,sum(totalshares) as totalshare,count(purchaseprice) as countofpurchase from sharestable where stockid="&r("stockid"),conn
av = cdbl(rr("sumofpurchase")) / cdbl(rr("totalshare"))
r("currentprice") = av
r.update
r.movenext
wend
%>
<%
set rsb = Server.CreateObject("ADODB.RECORDSET")
rsb.open "select * from stock where userpetid="&session("petshare"),conn,3,2
%>
Place a Buy Order
<% chkmenu=11 %>
<%
if not session("petitemid")="" then
set rsp =Server.CreateObject("adodb.recordset")
rsp.open "SELECT UserPetTable.userpetName, PetTable.petName, UserPetTable.energylevel, PetTable.smallimg FROM PetTable INNER JOIN UserPetTable ON PetTable.petId = UserPetTable.petId WHERE (((UserPetTable.userPetId)=" & session("petitemid") & "));",conn
if not rsp.eof then
%>
" width="34" height="34">
Pet Name
<%=rsp("userpetname")%>
Pet Type
<%=rsp("petname")%>
Energy Level
<%=rsp("energylevel")%>
<%end if
end if
%>
<%set rsi = Server.CreateObject("adodb.recordset")
rsi.open "SELECT sharestable.*, UserPetTable.Companyname FROM UserPetTable INNER JOIN sharestable ON UserPetTable.userPetId = sharestable.userpetid WHERE (((UserPetTable.userpetid)=" & session("petitemid")&"));",conn ,adOpenStatic, adLockReadOnly
if not rsi.eof then
rsi.move clng(request("total"))+0,1
%>
Company Name
Shares qty
0
<%else%>
<%=request("total")%>
<%end if%>
" >
<%for i=0 to 4
if not rsi.eof then
%>
<%
set rsstockcompany = Server.CreateObject("ADODB.RECORDSET")
rsstockcompany.open "SELECT UserPetTable.Companyname FROM UserPetTable INNER JOIN stock ON UserPetTable.userPetId = stock.userpetid WHERE (((stock.Stockid)="&rsi("stockid")&"));",conn
if not rsstockcompany.eof then
Response.Write(rsstockcompany("Companyname"))
end if
%>