ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[±Ð¾Ç] (¹ê¾Ô±MÃD) ¦Û°Ê¤Æ²¼¿ïµ{¦¡ ²¼¿ï¨Ï¥Î¤¶­±½g

[±Ð¾Ç] (¹ê¾Ô±MÃD) ¦Û°Ê¤Æ²¼¿ïµ{¦¡ ²¼¿ï¨Ï¥Î¤¶­±½g

·í§Ú­Ì¦b¡y¦Û°Ê¤Æ²¼¿ïµ{¦¡¡z¤§¡yºÞ²z¤¶­±¡z¤¤¡A§ó°Ê¤F²¼¿ï¶µ¥Ø¡A±N¼vÅT§Ú­Ì²¼¿ï¡y¨Ï¥Î¤¶­±¡zªºµ{¦¡ºô­¶Åã¥Ü¤º®e¡A¬°¤F¦]À³ºÞ²z¤¶­±¹ï²¼¿ï¶µ¥ØÅܰʪº¥i¯à©Ê¡A§Ú­Ì¦b¨Ï¥Î¤¶­±ªºµ{¦¡³]­p®É¬O¤£¥i¥H¨Ï¥Î©T©wÄæ¦ì©ïÀYªºÅã¥Ü¤è¦¡¡I¤]´N¬O»¡·í§Ú­Ì­nŪ¨ú¸ê®Æ®w¸ê®Æ®É¥²¶·±Ä¥Î¡yFields¶°¦Xª«¥ó¡zªºÆ[©À¨Ó¦s¨úÄæ¦ì¸ê®Æ¡C

¡@Ãö©ó¹w¨¾­«½Æ§ë²¼ªº¤èªk§Ú­Ì¤D¬O¨Ï¥ÎCookiesª«¥óªº¤è¦¡¨Ó³]­p¡A¹w¨¾­«½Æ§ë²¼ªº¤èªk­ì²z½Ð°Ñ¦Òµ§ªÌ¤§«e©Òµoªí¤§½d¨Ò¡u½u¤W²¼¿ï¡v¡A¥»½d¨Ò¥Ü½dªº­«ÂI¬°°t¦X¡yºÞ²z¤¶­±¡z¤¤§ó°Ê²¼¿ï¶µ¥Ø«á¡y¨Ï¥Î¤¶­±¡zªºµ{¦¡ºô­¶¦p¦ó¦]À³ªºµ{¦¡³]­p¤èªk!!

§ë²¼µ{¦¡ºô­¶
¨Ï¥ÎªÌ¤¶­±ªº²Õ¦¨¦@¤À¬°¤G­Ó³¡¤À¡I
vote3.asp¡G¥Î¨ÓÅã¥Ü¥Ø«eªº²¼¿ïµ²ªG¥H¤Î¶i¦æ§ë²¼°Ê§@ªºµ{¦¡¾÷¨î¡Avotesave3.asp¡G¶i¦æÀx¦s·s§ë²¼µ²ªGªºµ{¦¡¾÷¨î¡A·íµMÁÙ¦³¤@­Ó¸ê®Æ®w¡A¤£¹L³o­Ó¸ê®Æ®w»PºÞ²z¤¶­±¨Ï¥Îªº¬O¦P¤@­Ó¡C§Ú­Ì¥ý¨Ó¬Ý¬Ý§ë²¼µ{¦¡ºô­¶µ{¦¡³]­pªºÅܰʳ¡¤À¡G

­pºâÁ`§ë²¼¼Æ
¡@§Ú­Ì¤§«e­pºâÁ`§ë²¼¼Æªº¤è¦¡¬O¸ê®Æ¿ý¤¤©Ò¦³ªºÄæ¦ì­È¥[Á`°_¨Ó¡A¦Ó¥B¬O¥HÄæ¦ì©ïÀY¬°Åª¨úÄæ¦ì­Èªº¨Ì¾Ú¡A¦p¤U¹Ïºñ¦â³¡¤Àµ{¦¡±Ô­z¡G

8-13.png

¥i¬O²{¦b§Ú­Ìªº²¼¿ïµ{¦¡¬O¥i¥HÀH®É§ïÅܲ¼¿ï¶µ¥Ø(¤]´N¬O­ì¨ÓªºÄæ¦ì©ïÀY)¡A¦P®É¸ê®Æ®wªº³]­p¤è¦¡¤]¥Ñ¾î¦V®æ¦¡§ï¬°ª½¦Vªº³]­p¤è¦¡¡A¦p¤U¹Ï¡I

8-12.png

¦]¦¹¡A§Ú­Ì­n­pºâÁ`§ë²¼¼Æ¥²¶·§ï¥Î¤U¦C¤è¦¡¡G

  • ¥ý§Q¥ÎMoveFirst¤èªk±N§@¥Î¤¤¸ê®Æ¿ýªº¦ì¸m²¾¦Ü²Ä¤@µ§¸ê®Æ¤W¡C
  • ³]©w¤@Àx¦sÁ`§ë²¼¼ÆªºÅܼÆVotepeople¡A¨Ã±NÅܼƤº¸ê®Æ­È¹w³]¬°"0"¡C
  • §Q¥ÎÂŦⳡ¤ÀªºFor°j°é(¥~°j°é)¡A¥[¤WMoveNext¤èªk³v¦¸²¾°Ê§@¥Î¤¤¸ê®Æ¿ýªº¦ì¸m¡C
  • ºñ¦â³¡¤ÀªºFor°j°é(¤º°j°é)¡AÀHµÛ§@¥Î¤¤¸ê®Æ¿ýªº¦ì¸m§ïÅÜ¡A¨ú¥X¸ê®Æ¿ý¤¤²Ä¢°­ÓÄæ¦ì(²¼¼ÆÄæ¦ì)ªº¸ê®Æ­È¥X¨Ó°µÁ`²¼¼Æªº²Ö¥[­pºâ¡C


8-15.png
¤ß¦w¡A¥­¦w   
µoªí¥ô¦óµL·N¸qªº·PÁ©ÎÄé¤ô¤å³¹¤@«ß¬å,¬Ã±¤±b¸¹,½Ð¸Ô¾\ª©³W!!

³]©w²¼¼Æªø±ø¹Ï¹Ï¤ùÅã¥Ü¼e«×
¡@¦b±o¨ìÁ`§ë²¼¤H¼Æªº¼Æ¾Ú¸ê®Æ«á¡A±µµÛ´N¬O¶i¦æ²¼¿ï¹Ï§Î«¬ªºÅã¥Ü¼e«×³]©w¡A¦p¤U¹Ï©Ò¥Ü¡C

8-16.png


  • §Q¥ÎMoveFirst¤èªk±N§@¥Î¤¤¸ê®Æ¿ýªº¦ì¸m²¾¦Ü²Ä¤@µ§¸ê®Æ¤W¡C
  • «Å§i«Ø¥ß¤@­ÓÀx¦s¦U²¼¿ï¶µ¥Ø¥Ø«e±o²¼¼Æªº°}¦Clinelong¡C
  • §Q¥ÎÂŦⳡ¤ÀªºFor°j°é(¥~°j°é)¡A¥[¤WMoveNext¤èªk³v¦¸²¾°Ê§@¥Î¤¤¸ê®Æ¿ýªº¦ì¸m¡C
  • ºñ¦â³¡¤ÀªºFor°j°é(¤º°j°é)¡AÀHµÛ§@¥Î¤¤¸ê®Æ¿ýªº¦ì¸m§ïÅÜ¡A¨ú¥X¸ê®Æ¿ý¤¤²Ä¢°­ÓÄæ¦ì(²¼¼ÆÄæ¦ì)ªº¸ê®Æ­È¥X¨Ó°µ¹Bºâ¡A¦ý¬O¦b¶i¦æ¹Ï¤ù¼e«×¹Bºâ¤§«e¡A§Ú­Ì¥²¶·¥ý§Q¥ÎIF±Ô­z§PÂ_²¼¿ï¶µ¥Øªº²¼¼Æ¬O¤£¬O¢¯¡I¦pªG¤£¬O¢¯§Ú­Ì¤~¶}©l¶i¦æ¹Ï¤ù¼e«×¹Bºâ¡I¹Bºâ©Ò±oªº²¼¿ï¶µ¥Ø¹Ï¤ù¼e«×­È¦A±N¨äÀx©ñ¸m¦Ü°}¦C¤¤¡C


­pºâ¥X¦U­Ó²¼¿ï¶µ¥Ø¹Ï¤ù¼e«×­È«á¡A§Q¥ÎFor--Next°j°éªº¤è¦¡°t¦XHTMLªí®æ¼ÐÅÒ±Ô­z¨Ó«Ø¥ß²¼¿ï«ö¶s¡B¿é¥X²¼¿ï¶µ¥Ø¦WºÙ»P±o²¼¹Ï§Î¤Î¥Ø«e²¼¼Æ¡A¨£¤U¹Ï¡C




  • §Q¥ÎMoveFirst¤èªk±N§@¥Î¤¤¸ê®Æ¿ýªº¦ì¸m²¾¦Ü²Ä¤@µ§¸ê®Æ¤W¡C
  • §Q¥ÎÂŦⳡ¤ÀªºFor°j°é(¥~°j°é)¡A¥[¤WMoveNext¤èªk³v¦¸²¾°Ê§@¥Î¤¤¸ê®Æ¿ýªº¦ì¸m¡C
  • For°j°é¤º¡AÀHµÛ§@¥Î¤¤¸ê®Æ¿ýªº¦ì¸m§ïÅÜ¡A«Ø¥ß¦U²¼¿ï¶µ¥Ø¬Û¹ïÀ³ªº§ë²¼«ö¶s¡B¨ú¥X¦U²¼¿ï¶µ¥Øªº¦WºÙ¡BÅã¥Ü±o²¼¹Ï§Î¤Î¥Ø«e²¼¼Æ¡A¨Ã±N¦U¶µ¸ê®Æ¸m©ñ©óªí®æ¤§¤¤¡C



´£¥Ü:

  • ¨C·íÂŦⳡ¤ÀªºFor°j°é°õ¦æ¤@¦¸¤§«á¡A´N¥²¶·§Q¥ÎMoveNext¤èªk±N§@¥Î¤¤ªº¸ê®Æ¿ý©¹¤U²¾°Ê¤@µ§¡A³o¼Ë¤~¯àÀò±o¤U¤@­Ó²¼¿ï¶µ¥Øªº¦WºÙ¥H¤Î¥Ø«eªº±o²¼¼Æ¸ê®Æ¡C
  • ¡yResponse.Write Chr(10)¡z¿é¥X¤@­Ó´«¦æ²Å¸¹¡A¨Ïµ{¦¡°õ¦æ«á¿é¥XªºHtml¼ÐÅÒ±Ô­z¯à¾ã»ôªº±Æ¦C¡C
  • ¹Ï§Îªº¼e«×¤D¬O¨ú¥X°}¦Clinelong¤¤¬Û¹ïÀ³ªº¤¸¯À¸ê®Æ­È¡C



Vote3.asp
  1. <%
  2. er=Request.Cookies("er")
  3. IF err="" then err=empty
  4. '«Ø¥ß¸ê®Æ®w³sµ²ª«¥ó
  5.         Set conobject = Server.CreateObject("ADODB.Connection")
  6.         DBPath = Server.MapPath("vote.mdb")
  7. '³sµ²¸ê®Æ®w       
  8.         conobject.Open "Driver={Microsoft Access Driver (*.mdb)};DBQ="&DBPath
  9. '«Ø¥ß¸ê®Æ®w¦s¨úª«¥ó       
  10.         Set RS=Server.CreateObject("ADODB.Recordset")
  11. '¥´¶}¸ê®Æªí       
  12.         RS.Open "Select * from student",conobject,1,1
  13.        
  14. '­pºâÁ`§ë²¼¼Æ
  15. Rs.MoveFirst       
  16. VotePeople=0
  17. For Itemline=0 To Rs.recordcount-1
  18.       For Item=0 To Rs.Fields.Count-1
  19.        VotePeople=Votepeople+Rs.Fields(1).Value
  20.       Next
  21.           Rs.MoveNext
  22.           If Rs.Eof Then Exit For
  23. Next          
  24. '³]©w±o²¼²v¹Ïªí¼e«×
  25. Rs.MoveFirst
  26. Dim linelong(4)
  27. For Itemline=0 To Rs.recordcount-1
  28.       For Item=0 To Rs.Fields.Count-1
  29.                         IF Votepeople+Rs.Fields(1).Value >0 Then
  30.                                 linelong(Itemline) = 500*Rs.Fields(1).Value/VotePeople
  31.                         End If
  32.       Next
  33. Rs.MoveNext
  34. If Rs.Eof Then Exit For
  35. Next               

  36. '§ë²¼Àˬd
  37. IF Request.Cookies("checkvote")="yes" then
  38. msg="§A¤w¸g§ë¹L²¼¤F!¥u¯àÆ[¬Ý§ë²¼µ²ªG!"
  39. VoteButton="no"

  40. ElseIF er="yes" Then
  41. Response.Cookies("er")="no"
  42. msg="¤§«eªº§ë²¼µL®Ä,½Ð¿ï¾Ü¤@¦ì­Ô¿ï¤H­«·s§ë²¼"
  43. VoteButton="yes"

  44. Else
  45. Response.Cookies("checkvote")="yes"
  46. msg="§Aªº¤@²¼¿ï¼Ò½d¥Í"
  47. VoteButton="yes"
  48. End IF
  49. %>
  50. <CENTER>
  51. <P><img border="0" src="logo.gif"><br>
  52. <font color="#0000FF"><%=msg%></font></P>
  53. <form method="POST" action="votesave3.asp">
  54.   <table border="1">
  55.     <tr>
  56.       <td bgcolor="#FF3399"><font color="#FFFFFF">°é²¼³B</font></td>
  57.       <td bgcolor="#FF3399"><font color="#FFFFFF">­Ô¿ï¤H</font></td>
  58.       <td bgcolor="#FF3399"><font color="#FFFFFF">±o²¼¼Æ</font></td>
  59.     </tr>
  60.      <%   

  61. Rs.MoveFirst
  62. For Itemline=0 To Rs.recordcount-1
  63.       Response.Write "<TR>"
  64.              Response.Write "<TD><input type=radio name=vote  value=" & Itemline & "></TD>"
  65.              Response.Write chr(10)
  66.              Response.Write "<TD>" & Rs.Fields(0).Value & "</TD>"
  67.              Response.Write chr(10)
  68.         Response.Write "<TD><img border=0 src=vote.gif Height=5 Width=" & linelong(Itemline) & ">"
  69.              Response.Write chr(10)
  70.         Response.Write Rs.Fields(1).Value & "²¼</TD>"
  71.              Response.Write chr(10)
  72.       Response.Write "</TR>"
  73.           Rs.MoveNext
  74.           'If Rs.Eof Then Exit For
  75. Next          
  76.    
  77.     %>
  78.   </table>
  79. <%IF VoteButton="yes" then %>
  80. <p><input type="submit" value="§ë¤U¯«¸tªº¤@²¼"></p>
  81. <% End IF %>
  82. </form>
  83. </CENTER>
½Æ»s¥N½X
¤ß¦w¡A¥­¦w   
µoªí¥ô¦óµL·N¸qªº·PÁ©ÎÄé¤ô¤å³¹¤@«ß¬å,¬Ã±¤±b¸¹,½Ð¸Ô¾\ª©³W!!

TOP

¦s¨ú¯S©w¸ê®Æ¿ý
·í§Ú­Ì¶}±Ò¸ê®Æ®w¸ê®Æªí«á¡A¥Ø«e§@¥Î¤¤ªº¸ê®Æ¿ý¦ì¸m´N·|¬O¦b²Ä¤@µ§¸ê®Æ¤W¡A¨º¦pªG§Ú­Ì­nŪ¨úªº¸ê®Æ¦ì¸m¦b²Ä¢´¢¯µ§¸ê®Æ¿ý¤W¡A­þ«ç»ò¿ì¡H°ò¦ªº¸Ñ¨M¤è¦¡¬O§Q¥ÎMoveNext¤èªk±N§@¥Î¤¤ªº¸ê®Æ¿ý¦ì¸m¤@µ§¤@µ§ªº©¹¤U²¾°Ê¡A¦ý¬O¡A¦³¤@­Ó§ó²«Kªº¤èªk¡G¨Ï¥ÎAbsolutePositionÄÝ©Ê¡AAbsolutePositionÄÝ©Ê¥i¥H¥ß§Y±N§Ú­Ì§@¥Î¤¤ªº¸ê®Æ¿ý¦ì¸m²¾°Ê«ü©w¤ñ¼Æªº¸ê®Æ¤W¡A¨ä¨Ï¥Î®æ¦¡¦p¤U¡C

8-18.png

ª`·N¡G

  • «ü©w§@¥Î¤¤ªº¸ê®Æ¿ý¦ì¸m¨ä¦ì¸m½s¸¹¬O±q"¢°"¶}©l¡A¤]´N¬O»¡¤W¹Ï¤¤ªº¢æ­È¥²¶·µ¥©ó©Î¤j©ó"¢°"¡I·íµM¡A¨ä³Ì¤j­È¬O¥²¶·¤p©ó©Îµ¥©ó¸ê®Æªí¤¤ªº¸ê®ÆÁ`µ§¼Æ!!
  • «Ø¥ß¸ê®Æ®w¦s¨úªº¸ê®Æ¿ýRecordsetª«¥ó®É¨ä«ü©wÂê©wÃþ«¬°Ñ¼Æ(°Ñ¼Æ¢³)¡A¤£¥i«ü©w¬°"1"¶}±Ò°ßŪ¸ê®Æ¿ý¡A§_«h±N·|¤Þµo¤U¹Ïªº¿ù»~°T®§¡G
    8-19.png


§ë²¼µ²ªGÀx¦sµ{¦¡
§ë²¼µ²ªGÀx¦sµ{¦¡¡yvotesave3.asp¡z¡A¦b¥»µ{¦¡¤¤§¹¥þ¨S¦³ºô­¶¸ê®ÆªºÅã¥Ü¡A¥»µ{¦¡¥u­t³d±N§ë²¼µ{¦¡ºô­¶¤¤©Ò¶Ç°e¹L¨Óªº§ë²¼¸ê®Æ¸ê®Æ§ó·s¨ì¸ê®Æ®w¤¤¡AµM«á±N³sµ²Âà¦V¦^§ë²¼µ{¦¡ºô­¶¡C



±N±µ¦¬¨Ó¦Û§ë²¼µ{¦¡ºô­¶¤¤ªí³æ©Ò¶Ç°e¹L¨Óªº§ë²¼¸ê®Æ­È(voteÅܼƪº­È)¡A§@¬°Select Case ±Ô­zªº¤ñ¹ï¨Ì¾Ú¡C

  • §Q¥Î¦h°õ¦æ¸ô®|ªº Select Case ±Ô­z¨Ó¨M©w¥Ø«eªº§@ºØ¤¤¸ê®Æ¿ý¦ì¸mÀ³¸Ó²¾¦Ü­þ¤@µ§¸ê®Æ¤W¡C
  • ±N§@¥Î¤¤¸ê®Æ¿ýªº²Ä"¢°"­Ó¸ê®ÆÄæ¦ì(±o²¼¼Æ)­È¥[¤@¡A¥Nªí¸Ó²¼¿ï¶µ¥ØÀò±o¿ï²¼¡C
  • §Q¥ÎUpdate¤èªk±N·sªº§ë²¼µ²ªG§ó·s¼g¤J¨ì¸ê®Æ®w¤¤¡C
  • §Q¥ÎResponse.Redirect "vote¢².asp" µ{¦¡±Ô­zÂà¦V³sµ²¦^§ë²¼µ{¦¡ºô­¶vote¢².asp¥hÅã¥Ü³Ì·sªº§ë²¼µ²ªG¡C



Votesave3.asp
  1. <%
  2. '§PÂ_¬O§_¦³¥¿½T§ë²¼
  3. vote=Request("vote")
  4. IF vote=empty then
  5. Response.Cookies("er")="yes"
  6. Response.Cookies("checkvote")="no"
  7. Response.Redirect "vote3.asp"
  8. Else
  9. Response.Cookies("checkvote")="yes"
  10. '«Ø¥ß¸ê®Æ®w³sµ²ª«¥ó
  11.         Set conobject = Server.CreateObject("ADODB.Connection")
  12.         DBPath = Server.MapPath("vote.mdb")
  13. '³sµ²¸ê®Æ®w       
  14.         conobject.Open "Driver={Microsoft Access Driver (*.mdb)};DBQ="&DBPath
  15. '«Ø¥ß¸ê®Æ®w¦s¨úª«¥ó       
  16.         Set RS=Server.CreateObject("ADODB.Recordset")
  17. '¥´¶}¸ê®Æªí       
  18.         RS.Open "Select * from student",conobject,1,3
  19. '§ó·s§ë²¼µ²ªG        
  20. Select case vote
  21.         case 0
  22.                  RS.absoluteposition=1
  23.                  Rs(1)=Rs(1)+1
  24.         case 1
  25.                  RS.absoluteposition=2
  26.                  Rs(1)=Rs(1)+1
  27.         case 2
  28.                  RS.absoluteposition=3
  29.                  Rs(1)=Rs(1)+1
  30.         case 3
  31.                  RS.absoluteposition=4
  32.                  Rs(1)=Rs(1)+1
  33.     case 4
  34.                  RS.absoluteposition=5
  35.                  Rs(1)=Rs(1)+1
  36. end Select
  37. RS.UPdate
  38. End If
  39. Rs.Close
  40. Conobject.Close
  41. Response.Redirect "vote3.asp"

  42. %>
½Æ»s¥N½X
ÁöµM³o­Óµ{¦¡¥i¥H°õ¦æ¡A¦ý¬OÁÙ¬O¦³¤@­Ó¯ÊÂIËç¡I³o­Ó¯ÊÂI¥Ñ±z¨Óµo²{¡Aµo²{«á¼g­ÓE-mailµ¹¤p»x¡AÁÙ­n§i¶D¤p»x§Aªº¸Ñ¨M¿ìªk³á¡I²Ä¤@­Ó§i¶D¤p»xªº¡A§Ú·|¥Zµn¦bºô¯¸¤W¡AµM«áA¤@¥÷§ª«µ¹§A(¦]¬°¤p»x¨S°]¤O¡A©Ò¥H¥u¦n¡K¡K¨þ)¡C


(¹ê¾Ô±MÃD) ¦Û°Ê¤Æ²¼¿ïµ{¦¡ ²¼¿ï¨Ï¥Î¤¶­±½g§¹¾ã½d¨ÒÀ£ÁYÀÉ: vote4.zip (24.38 KB)
¤ß¦w¡A¥­¦w   
µoªí¥ô¦óµL·N¸qªº·PÁ©ÎÄé¤ô¤å³¹¤@«ß¬å,¬Ã±¤±b¸¹,½Ð¸Ô¾\ª©³W!!

TOP

        ÀR«ä¦Û¦b : §Ñ¥\¤£§Ñ¹L¡A§Ñ«è¤£§Ñ®¦¡C
ªð¦^¦Cªí ¤W¤@¥DÃD