By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,918 Members | 1,816 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,918 IT Pros & Developers. It's quick & easy.

Change from case to do all case....

P: 2
Hi I am new in ASP programming so I do use the very basic and simple way to do all my stuff. Now I do really got stuck at how can I loop thru the calculation for all my selection.. My full code is as below:-


Expand|Select|Wrap|Line Numbers
  1.  <% 
  2. tBegin = request("beginww") 
  3. tEnd = request("endww") 
  4. tYear = request("wwyear") 
  5. %> 
  6. <body> 
  7.  
  8. <form name= "frmsporttype" method="POST"> 
  9. Year: <select name="wwyear" id="wwyear"> 
  10. <%if tYear = "" then tYear = Year(date) 
  11. for t = 2005 to tYear%> 
  12. <option value="<%=t%>" <%if t = cint(tYear) then%>selected<%end if%>><%=t%></option> 
  13. <%next%> 
  14. </select> 
  15. Start Week: <select name="beginww" id="beginww"> 
  16. <% if tBegin = "" then tBegin = 1 
  17. for t = 1 to 53%> 
  18. <option value="<%=t%>" <%if t = cint(tBegin) then%>selected<%end if%>><%=t%></option> 
  19. <%next%> 
  20. </select> 
  21. End Week: <select name="endww" id="endww"> 
  22. <% if tEnd = "" then tEnd = 1 
  23. for t = 1 to 53%> 
  24. <option value="<%=t%>" <%if t = cint(tEnd) then%>selected<%end if%>><%=t%></option> 
  25. <%next%> 
  26. </select> 
  27. Sport Type: 
  28. <select name="exercise" id="exercise"> 
  29. <option Value="A">All Sport 
  30. <option Value = "Golf">Golf 
  31. <option Value = "Table">Table Tennis 
  32. <option Value = "Tenis">Tennis 
  33. <option Value = "Soccer">Soccer 
  34. <option Value = "Basket">Basketball 
  35. <option Value = "Bowling">Bowling 
  36. <option value="<%=sporttype%>"Selected</option> 
  37. </select> 
  38.  
  39.  
  40. <INPUT TYPE="submit" runat="server" VALUE="Cal"></INPUT> 
  41. </form> 
  42.  
  43. <% 
  44. if Request.ServerVariables("REQUEST_METHOD") = "POST" then 
  45. %> 
  46. <table width="100%" align="center" bgcolor="#0d5692"> 
  47. <tr> 
  48. <td width="7%" align="center" bgcolor="#ffffff"><font face="verdana" size="2"><b>Sport</b></font></td> 
  49. <td width="5%" align="center" bgcolor="#ffffff"><font face="verdana" size="2"><b>Average 
  50. Hour Play</b></font></td> 
  51. <td width="5%" align="center" bgcolor="#ffffff"><font face="verdana" size="2"><b>Average 
  52. Day Play</b></font></td> 
  53. <td width="7%" align="center" bgcolor="#ffffff"><font face="verdana" size="2"><b>Total 
  54. Record</b></font></td> 
  55. </tr> 
  56.  
  57. <% 
  58. SET RS=CreateObject("ADODB.Recordset") 'create a recordset 
  59. select case request ("exercise") 
  60. case "A" 
  61. sql="select hour, day from tblFiles where sport = '%' and workweek between " & tBegin & " and " & tEnd & " and Year = " & tYear & " Order by date DESC" 
  62. Sportid= "All Sport" 
  63. case "Golf" 
  64. sql="select hour, day from tblFiles where sport Like '%Golf%' and workweek between " & tBegin & " and " & tEnd & " and Year = " & tYear & " Order by date DESC" 
  65. Sportid= "Golf" 
  66. case "Table" 
  67. sql="select hour, day from tblFiles where sport Like '%Table' and workweek between " & tBegin & " and " & tEnd & " and Year = " & tYear & " Order by date DESC" 
  68. Sportid= "Table Tennis" 
  69. case "Tennis" 
  70. sql="select hour, day from tblFiles where sport Like '%Tennis' and not like '%Table" and workweek between " & tBegin & " and " & tEnd & " and Year = " & tYear & " Order by date DESC" 
  71. Sportid= "Tennis" 
  72. case "Soccer" 
  73. sql="select hour, day from tblFiles where sport Like '%Soccer' and workweek between " & tBegin & " and " & tEnd & " and Year = " & tYear & " Order by date DESC" 
  74. Sportid= "Soccer" 
  75. case "Basket" 
  76. sql="select hour, day from tblFiles where sport Like '%Basket' and workweek between " & tBegin & " and " & tEnd & " and Year = " & tYear & " Order by date DESC" 
  77. Sportid= "Basketball" 
  78. case "Bowling" 
  79. sql="select hour, day from tblFiles where sport Like '%Bowling' and workweek between " & tBegin & " and " & tEnd & " and Year = " & tYear & " Order by date DESC" 
  80. Sportid= "Bowling" 
  81. End select 
  82. RS.Open sql,conn,1,2 
  83. sMsg = " No Data Within The WorkWeek you Select Please Select Others WorkWeek." 
  84. if rs.recordcount < 1 Then 
  85. response.write (sMsg) 
  86. else 
  87. if rs.recordcount >= 30 then 
  88. SET RS=CreateObject("ADODB.Recordset") 'create a recordset 
  89. select case request ("exercise") 
  90. case "A" 
  91. sql="select hour, day from tblFiles where sport = '%' and workweek between " & tBegin & " and " & tEnd & " and Year = " & tYear & " Order by date DESC" 
  92. Sportid= "All Sport" 
  93. case "Golf" 
  94. sql="select hour, day from tblFiles where sport Like '%Golf%' and workweek between " & tBegin & " and " & tEnd & " and Year = " & tYear & " Order by date DESC" 
  95. Sportid= "Golf" 
  96. case "Table" 
  97. sql="select hour, day from tblFiles where sport Like '%Table' and workweek between " & tBegin & " and " & tEnd & " and Year = " & tYear & " Order by date DESC" 
  98. Sportid= "Table Tennis" 
  99. case "Tennis" 
  100. sql="select hour, day from tblFiles where sport Like '%Tennis' and not like '%Table" and workweek between " & tBegin & " and " & tEnd & " and Year = " & tYear & " Order by date DESC" 
  101. Sportid= "Tennis" 
  102. case "Soccer" 
  103. sql="select hour, day from tblFiles where sport Like '%Soccer' and workweek between " & tBegin & " and " & tEnd & " and Year = " & tYear & " Order by date DESC" 
  104. Sportid= "Soccer" 
  105. case "Basket" 
  106. sql="select hour, day from tblFiles where sport Like '%Basket' and workweek between " & tBegin & " and " & tEnd & " and Year = " & tYear & " Order by date DESC" 
  107. Sportid= "Basketball" 
  108. case "Bowling" 
  109. sql="select hour, day from tblFiles where sport Like '%Bowling' and workweek between " & tBegin & " and " & tEnd & " and Year = " & tYear & " Order by date DESC" 
  110. Sportid= "Bowling" 
  111. End select 
  112.  
  113. Else 
  114.  
  115. SET RS=CreateObject("ADODB.Recordset") 'create a recordset 
  116. select case request ("exercise") 
  117. case "A" 
  118. sql="select hour, day from tblFiles where sport = '%' and workweek <= " & tEnd & " and Year = " & tYear & " Order by date DESC" 
  119. Sportid= "All Sport" 
  120. case "Golf" 
  121. sql="select hour, day from tblFiles where sport Like '%Golf%' and workweek <= " & tEnd & " and Year = " & tYear & " Order by date DESC" 
  122. Sportid= "Golf" 
  123. case "Table" 
  124. sql="select hour, day from tblFiles where sport Like '%Table' and workweek <= " & tEnd & " and Year = " & tYear & " Order by date DESC" 
  125. Sportid= "Table Tennis" 
  126. case "Tennis" 
  127. sql="select hour, day from tblFiles where sport Like '%Tennis' and not like '%Tableand workweek <= " & tEnd & " and Year = " & tYear & " Order by date DESC" 
  128. Sportid= "Tennis" 
  129. case "Soccer" 
  130. sql="select hour, day from tblFiles where sport Like '%Soccer' and workweek <= " & tEnd & " and Year = " & tYear & " Order by date DESC" 
  131. Sportid= "Soccer" 
  132. case "Basket" 
  133. sql="select hour, day from tblFiles where sport Like '%Basket' and workweek <= " & tEnd & " and Year = " & tYear & " Order by date DESC" 
  134. Sportid= "Basketball" 
  135. case "Bowling" 
  136. sql="select hour, day from tblFiles where sport Like '%Bowling' and workweek <= " & tEnd & " and Year = " & tYear & " Order by date DESC" 
  137. Sportid= "Bowling" 
  138. End select 
  139.  
  140.  
  141. end if 
  142. Rs.open sql,conn,1,2 
  143. tday=0 
  144. thour=0 
  145. count=0 
  146. Do until rs.eof 
  147. Hour = RS("hour") 
  148. Day = rs("day") 
  149. count = count + 1 
  150. tday= tday + day 
  151. dayave= tday/ count 
  152. thour= thour + hour 
  153. hourave= thour/ count 
  154.  
  155. rs.movenext 
  156. Loop%> 
  157.  
  158.  
  159.  
  160. <tr> 
  161. <Td width="7%" bgcolor="#f1f1f1" align="center"><font face="verdana" size="2"><%=Sportid%></font></Td> 
  162.  
  163. <Td width="7%" bgcolor="#f1f1f1" align="center"><font face="verdana" size="2"><%=FormatNumber(dayavg,2)%></font></Td> 
  164.  
  165. <Td width="7%" bgcolor="#f1f1f1" align="center"><font face="verdana" size="2"><%=FormatNumber(houravg,2)%></font></Td> 
  166.  
  167. </tr> 
  168.  
  169. end if%> 
  170. </table> 
  171. </body> 
  172.  
Above is all my code, as now I can only getting the data base on what I select, how can I getting all data in one table that I want in one click?Help and solution are appreciated.
Tks
Aug 10 '05 #1
Share this Question
Share on Google+
2 Replies


Expert Mod 100+
P: 2,328
are you asking how to display all the data/records from the table?
Aug 11 '05 #2

P: 2
are you asking how to display all the data/records from the table?
Hi tks for helping, My code is now go by case base on the user selection, What I want is how can I run all the case in one click..
Below is my case select code:-
SET RS=CreateObject("ADODB.Recordset") 'create a recordset
select case request ("pkgtype")
case "P"
sql="select Avg1, Range1, PkgType from tblFiles where Pkgtype Not Like '%G%' and workweek between " & tBegin & " and " & tEnd & " and Year = " & tYear & " Order by workweek DESC"
Pkgid= "All Sn/Pb Pkg"
case "G"
sql="select Avg1, Range1, PkgType from tblFiles where Pkgtype Like '%G%' and workweek between " & tBegin & " and " & tEnd & " and Year = " & tYear & " Order by workweek DESC"
Pkgid= "All Green Pkg"
case "208"
sql="select Avg1, Range1, PkgType from tblFiles where Pkgtype Like '%208' and Pkgtype Not Like '%G208' and workweek between " & tBegin & " and " & tEnd & " and Year = " & tYear & " Order by workweek DESC"
Pkgid= "PQFP 208"
end select

How can I run all case in one click?
Aug 12 '05 #3

Post your reply

Sign in to post your reply or Sign up for a free account.