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

13-3-6 §¹¾ãµ{¦¡¦Cªí

13-3-6 §¹¾ãµ{¦¡¦Cªí

13-3-6   §¹¾ãµ{¦¡¦Cªí
Indoor.php
  1. <?
  2. //©Ó±µ¥ÑIndoorªí³æ¶Ç¨Óªº¾Ç¸¹¡B©m¦W¸ê®Æ
  3. @$studentname=$_REQUEST["studentname"];
  4. @$number=$_REQUEST["number"];
  5. $Msg="";
  6. //¦pªGIndoorªí³æ¶Ç¨Óªº¾Ç¸¹¡B©m¦W¸ê®Æ¤£¬OªÅ¥Õªº
  7. //´N¶i¦æ»P¸ê®Æ®w¤¤¨ü´ú¾Ç¥Í¸ê®Æ¶i¦æ¤ñ¹ï
  8. IF (($studentname!="") && ($number!="")):
  9. //³sµ²MySQL Server
  10.     $conn = mysql_connect("localhost", "root", "12345a");
  11. //¿ï¾Ü¸ê®Æ®w
  12.     mysql_select_db("exam", $conn);
  13. //«ü©w´£¨ú¸ê®Æªº®Õ¹ï¦r¤¸ªí
  14.     mysql_query("set character set big5");
  15. //´£¨ú¸ê®ÆªºSQL©R¥O¦r¦ê
  16.    $SQL="SELECT * From student where ¾Ç¸¹='" .$number . "' and ©m¦W='" .$studentname . "'";
  17. //¶i¦æ¸ê®Æ¬d¸ß
  18. $RS=mysql_query($SQL);
  19. //¦pªG©m¦W¾Ç¸¹ÅçÃÒµL»~´N¶i¤J¸Õ¨÷ºô­¶
  20.    if ($Result=mysql_fetch_array($RS))
  21. {
  22. header("Location: question.php?" . $_SERVER["QUERY_STRING"]);
  23. }
  24. else
  25. {   
  26. //¦pªG§ä¤£¨ì¹ïÀ³ªº¾Ç¸¹»P©m¦W´NÅã¥Ü¿ù»~°T®§
  27.    IF ($Msg=="")
  28.    $Msg="©m¦W©Î¾Ç¸¹¿é¤J¦³¿ù»~¡I";
  29. }
  30. EndIf;
  31. ?>

  32. <html>
  33. <head>
  34. <meta http-equiv="Content-Type" content="text/html; charset=big5">
  35. <title>½u¤W¦Ò¸Õ-¸Õ³õ¤jªù</title>
  36. <script language="vbscript">
  37. <!--
  38. <!-- Àˬd¦³¨S¦³¿é¤J¸ê®Æ -->
  39. Function datacheck
  40. <!--§Q¥ÎVB ÀËÅç¦r¦êªø«×ªºLen¨ç¼ÆÅçÃÒÄæ¦ì¸ê®Æ¬O§_¶ñ¼g-->
  41. IF Len(document.indoor.studentname.value)=0 or Len(document.indoor.number.value)=0 then
  42. <!--¦pªG¦³Äæ¦ì¨S¦³¶ñ¼g«h¨q¥Xĵ§iµøµ¡-->
  43. msg="½Ð¿é¤J¸ê®Æ¡I"
  44. MsgBox msg,vbExclamation,"¿ù»~!"
  45. Exit Function
  46. End IF
  47. <!--¦pªGÄæ¦ì¸ê®Æ³£¦³¶ñ¼g«hIJµo¨­¤ÀÅçÃÒªºPHPµ{¦¡-->
  48. indoor.Submit
  49. End Function
  50. -->
  51. </script>
  52. </head>
  53. <body>
  54. <!-- ¿é¤J¸ê®Æªºªí³æ -->
  55. <p align="center"><font color="#FF0000" size="6" face="·s²Ó©úÅé">½u¤W¦Ò¸Õ-¸Õ³õ¤jªù</font></p>
  56. <!--¨ü´ú¾Ç¥Í©Ò¶ñªº¸ê®Æ¤£¥¿½T±N·|¥X²{¤@¬q¿ù»~°T®§-->
  57. <center><font color="red"><?=$Msg;?></font></center>
  58. <form method="get" name="indoor" >
  59.   <div align="center">
  60.     <table border="0" width="60%">
  61.       <tr>
  62.         <td width="50%">
  63.           <p align="right"><font color="#0000FF">©m¦W¡G</font></td>
  64.         <center>
  65.         <td width="50%"><input type="text" name="studentname" size="10" value="<?=$studentname;?>"></td>
  66.         </tr>
  67.       <tr>
  68.         <td width="50%">
  69.           <p align="right"><font color="#0000FF">¾Ç¸¹¡G</font></td>
  70.         <td width="50%"><input type="number" name="number" size="10" value="<?=$number;?>"></td>
  71.         </tr>
  72.         <tr>
  73.           <td width="100%" colspan="2">
  74.             <p align="center"><input type="button" value="¶i¤J¦Ò³õ" onclick="datacheck">
  75.             <input type="reset" value="­«·s¿é¤J"></td>
  76.         </tr>
  77.       </table>
  78.     </center>
  79.   </div>
  80. </form>
  81. </body>
  82. </html>
½Æ»s¥N½X
¤ß¦w¡A¥­¦w   
µoªí¥ô¦óµL·N¸qªº·PÁ©ÎÄé¤ô¤å³¹¤@«ß¬å,¬Ã±¤±b¸¹,½Ð¸Ô¾\ª©³W!!

Question.php
  1. <?
  2. //©Ó±µ¨Ó¦ÛIndoor.phpªº¾Ç¸¹¡B©m¦W¸ê®Æ
  3. $studentname=$_REQUEST["studentname"];
  4. $number=$_REQUEST["number"];
  5. //¶}±Òexam¸ê®Æ®w¤¤ªºask(ÃD¥Ø)¸ê®Æªí
  6. //³sµ²MySQL Server
  7.     $conn = mysql_connect("localhost", "root", "12345a");
  8. //¿ï¾Ü¸ê®Æ®w
  9.     mysql_select_db("exam", $conn);
  10. //«ü©w´£¨ú¸ê®Æªº®Õ¹ï¦r¤¸ªí
  11.     mysql_query("set character set big5");
  12. //´£¨ú¸ê®ÆªºSQL©R¥O¦r¦ê
  13.    $SQL="Select * From ask Order by ÃD¸¹";
  14. //¶i¦æ¸ê®Æ¬d¸ß
  15. $RS=mysql_query($SQL);
  16. ?>
  17. <HTML>
  18. <HEAD>
  19. <meta http-equiv="Content-Type" content="text/html; charset=big5">
  20. <TITLE>½u¤W¦Ò¸Õ-¸Õ¨÷ºô­¶</TITLE>
  21. </HEAD>
  22. <BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#800080">
  23. <div align="center"><font color="red" face="·s²Ó©úÅé" size="6">½u¤W¦Ò¸Õ-¸Õ¨÷ºô­¶</font></div>
  24. <form action="grad.php" method="get">
  25. <input type="hidden" name="studentname" value="<?=$studentname;?>">
  26. <input type="hidden" name="number" value="<?=$number;?>">  
  27. <?
  28. //Åã¥Ü¦ÒÃD
  29. //Ū¨ú¸ê®Æªíªº¸ê®Æ¿ýª½¨ì¸ê®Æ¿ý¥þ«×Ū¨ú§¹²¦
  30. //±N¸ê®Æ¿ýÂà´«¬°Äæ¦ì°}¦C¶°¦X
  31. While (($fielddatas=mysql_fetch_array($RS)))
  32. {
  33. //Åã¥ÜÃD¥Ø¤Î°t¤À  
  34.   echo "<hr size=1><font color=blue>" . $fielddatas[2]
  35.       . "¡B" . $fielddatas[3] . "&nbsp&nbsp(" . $fielddatas[9] . "¤À)</font><br>";
  36. //Åã¥Ü³Æ¿ïªºµª®×¶µ¥Ø                 
  37.   For($I=1;$I<=4;$I++)
  38.     {
  39.     echo "<font color=red>¡]" . $I . "¡^</font><input type=Radio "
  40.     . "name='No" . $fielddatas[2] . "' value=" . $I . ">" . $fielddatas["µª®×" .$I] ."<br>";
  41.     }
  42. }
  43. ?>
  44. <hr size="1">
  45. <div align="center"><input type="submit" value="¥æ¨÷"></div>
  46. </form>
  47. </BODY>
  48. </HTML>
½Æ»s¥N½X
¤ß¦w¡A¥­¦w   
µoªí¥ô¦óµL·N¸qªº·PÁ©ÎÄé¤ô¤å³¹¤@«ß¬å,¬Ã±¤±b¸¹,½Ð¸Ô¾\ª©³W!!

TOP

grad.php
  1. <HTML>
  2. <HEAD>
  3. <meta http-equiv="Content-Type" content="text/html; charset=big5">
  4. <TITLE>½u¤W¦Ò¸Õ-¦¨ÁZ§å§ï</TITLE>
  5. </HEAD>
  6. <BODY>
  7. <div align=center>
  8. <font color=green face=·s²Ó©úÅé size=6>½u¤W¦Ò¸Õ-¦¨ÁZ§å§ï</font>
  9. </div>
  10. <?
  11. //©Ó±µ¨Ó¦Ûquestion.phpªº¸ê®Æ
  12. $studentname=$_REQUEST["studentname"];
  13. $number=$_REQUEST["number"];
  14. //¶}±Òexam¸ê®Æ®w¤¤ªºask¦ÒÃD¸ê®Æªí
  15. //¦b¦¹¶}±Ò¸ê®Æ®w¬O¥Î¨ÓŪ¨úµª®×»P¼g¤J­pºâ«áªº¦¨ÁZ
  16. //¶}±Òexam¸ê®Æ®w¤¤ªºask(ÃD¥Ø)¸ê®Æªí
  17. //³sµ²MySQL Server
  18.     $conn = mysql_connect("localhost", "root", "12345a");
  19. //¿ï¾Ü¸ê®Æ®w
  20.     mysql_select_db("exam", $conn);
  21. //«ü©w´£¨ú¸ê®Æªº®Õ¹ï¦r¤¸ªí
  22.     mysql_query("set character set big5");
  23. //´£¨ú¸ê®ÆªºSQL©R¥O¦r¦ê
  24.    $SQL="Select * From ask Order by ÃD¸¹";
  25. //¶i¦æ¸ê®Æ¬d¸ß
  26. $RS=mysql_query($SQL);
  27. //¥ý±N­pºâªºÁ`¤À³]¬°¢¯   
  28.    $Score=0;

  29. //±N¥¿½Tµª®×¤Î¨ü´ú¾Ç¥Í¿ïªºµª®×¤@°_Åã¥Ü¤ñ¹ï   
  30. While (($fielddatas=mysql_fetch_array($RS)))
  31. {
  32.    $Sel=$_REQUEST["No" . $fielddatas[2]];
  33.    $Ans=$fielddatas[8];
  34. //­pºâ¦¨ÁZ¡Aµª¹ïªºÃD¥Ø¥[¤W¸ÓÃDÀ³±o¤À¼Æ
  35. //¦P®É§iª¾¸ÓÃD¥Ø¬Oµª¹ïÁÙ¬Oµª¿ù
  36.    IF (trim($Sel)==trim($Ans))
  37.        {
  38.           $Score=$Score+$fielddatas[9];
  39.           $RM="-->µª¹ï";
  40.         }
  41.    ELSE
  42.         {
  43.           $RM="-->µª¿ù";
  44.         }
  45.    $Ans=$fielddatas[$Ans+3];
  46.    $yourans=$fielddatas[$Sel+3];
  47. //±N¸ÕÃD§å§ïªºµ²ªG¿é¥X¦Üºô­¶¤¤
  48.    echo "<hr size=1>" . $fielddatas[2]
  49.        . "&nbsp&nbsp" . $fielddatas[3] . "<font color=red>" . $RM ."</font><br>";
  50. }


  51. //¶}±Òexam¤¤ªºstudent¸ê®Æªí¡AÅã¥Ü¨ü´ú¾Ç¥Íªº¦¨ÁZ  
  52. //±N§å§ï«áªº¨ü´ú¾Ç¥Í¦¨ÁZ¦s¤J¸ê®Æ®w¤¤
  53. $SQL="update student set ¤À¼Æ=" . $Score . " where ¾Ç¸¹='". $number . "' and ©m¦W='" .$studentname . "'";
  54. mysql_query($SQL);
  55. ?>
  56. <hr size="1">
  57. <!-- Åã¥ÜÀ³¦Ò¾Ç¥Íªº¸ê®Æ -->
  58. <table align="center" border="0" width="50%">
  59. <tr><td align="center" width="50%"><font color="blue">©m¦W¡G<?=$studentname;?></font></td>
  60. <td align="center" width="50%"><font color="blue">¾Ç¸¹¡G<?=$number;?></font></td></tr>
  61. </table>
  62. <!-- Åã¥ÜÀ³¦Ò¾Ç¥Íªº¦¨ÁZ -->
  63. <table align="center" border="1" width="50%">
  64. <tr><td align="center" width="50%">¦Ò¸Õ¶i«×</td>
  65. <td align="center" width="50%">¤À¼Æ</td></tr>
  66. <tr><td align="center">¥»¦¸´úÅ禨ÁZ</td><td align="center">
  67. <!--±N¦¨¿n¤£¤Î®æªº¤À¼Æ¥H¬õ¦âÅã¥Ü-->
  68. <?
  69.   IF ($Score<50)
  70.   echo "<font color=red>" . $Score . "¤À,¦º·í</font>";
  71.   ELSEIF ($Score<60)
  72.   echo "<font color=red>" . $Score . "¤À,¸É¦Ò</font>";
  73.   ELSE
  74.   echo $Score . "¤À,¤Î®æ";
  75. ?>
  76. </td></tr>
  77. </table>
  78. <hr size="1">
  79. <p>
  80. <!-- ­«·s¶ñ¼g´úÅç¨÷ -->
  81. </p>
  82. <div align="center">
  83. <a href="indoor.php?studentname=<?=$studentname;?>&number=<?=$number;?>">[¦A¦Ò¤@¦¸]</a>
  84. </div>
  85. </BODY>
  86. </HTML>
½Æ»s¥N½X
¤ß¦w¡A¥­¦w   
µoªí¥ô¦óµL·N¸qªº·PÁ©ÎÄé¤ô¤å³¹¤@«ß¬å,¬Ã±¤±b¸¹,½Ð¸Ô¾\ª©³W!!

TOP

§Ú·Q½Ð°Ý¤@¤U31~51¦æ ¬°¤°»ò§Ú¿ï¶µ³£¿ï¥¿½Tµª®× ¦ý¬O¨ìgrad.phpÅã¥Ü¥X¨Ó§Úªºµª®×³£¬O¿ùªº

TOP

$Sel=$_REQUEST["No" . $fielddatas[2]];
¤£¬O«Ü¤F¸Ñ³o¦æ,¬O§Ú¿ïªºµª®× ¥L·|¦s¦b$_REQUESTÅܼƤ¤¦b¸òANS¹ïµª®×¶Ü?
¨º"NO"¤S¬O¤°»ò©O?

TOP

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