473,508 Members | 2,744 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Change from case to do all case....

2 New Member
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
2 3190
Niheel
2,456 Recognized Expert Moderator Top Contributor
are you asking how to display all the data/records from the table?
Aug 11 '05 #2
cs168
2 New Member
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

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

Similar topics

8
15188
by: kchengso | last post by:
One of my printers in my printer.devicename call returns in lower case. Is it possible for me to change it to upper case? I am also wondering how, in the first place, this particular printer...
2
1844
by: Nick Calladine | last post by:
Is this possible to ... I wish to get the value of a dropdown select but gets is indexable value (dont know if that is the right term) if that is possible (the position it assigned get assigned...
1
2385
by: Richard Holliingsworth | last post by:
Hello: The group has new 'standards' for online forms and I need to change the 'style' of my existing forms (A2002). Can I do this? I can't find a way using the GUI or the properties. ...
2
2390
by: MLH | last post by:
What's the simplest way to allow a user of an A97 app to change password?
2
2013
by: Imran Aziz | last post by:
Hello All, I want to change the size of my hyper lnks in a repeater control dynamially using the onItemBound event, as under, but cannot seem to understand how to alter the properties to do...
6
5134
by: Jan | last post by:
Hi: I have created a secured database for a client. For various reasons, I don't want the client to have full persmissions for the database; they aren't in the admins group. I have instead tried...
1
6038
by: Sankalp | last post by:
Hi, I am using VB 2005. My application has many data bound controls. The connection is stored in the app.config file. I want the application to start with a default connection string and while...
2
1943
by: Denis | last post by:
How can you get the contents of a text box to change after for click out of it. Eg I have a text box on a form called Ownername. If some one enters a name in lower case that it automatically...
130
3229
by: Gianni Mariani | last post by:
Attached example CPP files makes it easier to post code and extract code from posts. It's unimaginable at this time where virtually any news reader is capable of dealing with attachments to stick...
56
6663
by: Adem | last post by:
C/C++ language proposal: Change the 'case expression' from "integral constant-expression" to "integral expression" The C++ Standard (ISO/IEC 14882, Second edition, 2003-10-15) says under...
0
7393
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7058
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7502
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5635
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5057
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3206
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3191
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
769
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
426
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.