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

11-2-3 ¥DÃD¶µ¥Ø¦Cªí»P·s¥DÃD¸ê®Æ³B²zµ{¦¡

11-2-3 ¥DÃD¶µ¥Ø¦Cªí»P·s¥DÃD¸ê®Æ³B²zµ{¦¡

11-2-3   ¥DÃD¶µ¥Ø¦Cªí»P·s¥DÃD¸ê®Æ³B²zµ{¦¡
°Q½×¶µ¥Ø¦Cªíµ{¦¡ºô­¶index.php¬O¶i¤J¡u°Q½×°Ï¡vªº¤jªùºô­¶¡A³o­Óºô­¶¥]§t¨â¤j³¡¤À¡A¤@¬O¥þ³¡°Q½×¶µ¥Øªº¦Cªí³¡¤À¡A¶i¤J¦¹¤@µ{¦¡ºô­¶«á¡A¦pªGÂI¿ï¤F¬Y¤@­Ó¤w¦s¦bªº°Q½×¶µ¥Ø¡y¥DÃD¡z¶W³sµ²¡A´N¥i¥H³sµ²¶i¤J¸Ó°Q½×¥DÃDªº¹ïÀ³°Q½×ºô­¶¡]join.php¡^¡A¦pªG·Q­nµoªí·sªº°Q½×¶µ¥Ø¡A´N¥iª½±µ¦bµ{¦¡ºô­¶¤U¤èªºµo¨¥ªí³æ¤¤¿é¤J¸ê®Æ¨Ó«Ø¥ß·sªº°Q½×¥DÃD¡G

¹Ï11-33  index.php¡C

¦]¦¹¡A§Ú­Ìµ{¦¡ªº³]­p´N¤À¬°¨â­Ó³¡¤À¡A¦b¥þ³¡°Q½×¶µ¥Øªº¦Cªí³¡¤À¡A§Ú­Ì¥u­n¶}±Ò¸ê®Æ®w¡AµM«á±N¡y¥D¼ÐÃD¡z¸ê®Æªí¤¤ªº¬ÛÃöÄæ¦ì¸ê®Æ¨ú¥X¨Ó¡A¨Ã¥B¥[¤W¬ÛÃöªºHTMLªí®æ¼ÐÅÒ²Õ¦X´N¥i§¹¦¨¥ô°È¡G
  1. <?
  2. //±N¸ê®Æ¿ýÂà´«¬°Äæ¦ì°}¦C¶°¦X
  3. While (($fielddatas=mysql_fetch_array($datalist)))
  4. {
  5. ?>
  6. <TR Valign=TOP>
  7. <TD NoWrap width="20%" bgcolor="#E8FFFF">
  8. <p align="center"><font size="2">
  9. <?=$fielddatas["µo¨¥¤é´Á"];?></font></TD>
  10. <TD width="20%" bgcolor="#E8FFFF">
  11. <p align="center"><font size="2">
  12. <?=$fielddatas["©m¦W"];?></font></TD>
  13. <TD width="50%" bgcolor="#E8FFFF">
  14. <A HREF=join.php?ID=<?=$fielddatas["¥D½s¸¹"];?>>
  15. <font size="2">
  16. <?=$fielddatas["¥DÃD"];?></font></A></TD>
  17. <TD width="10%" bgcolor="#E8FFFF">
  18. <p align="center"><font size="2">
  19. <?=$fielddatas["½g¼Æ"];?></font></TD>
  20. </TR>
  21. <?
  22. }
  23. ?>
½Æ»s¥N½X
§Q¥ÎWhile°j°é±Ô­z±N©Ò¦³¸ê®Æªí¤¤¸ê®Æ¿ýÄæ¦ìªº¸ê®Æ¥þ³¡¨ú¥X¦Cªí¡A°j°é±Ô­z°±¤î°õ¦æªº±ø¥ó¬° mysql_fetch_array()¨ç¼Æ¶Ç¦^False­È®É¡A·N«ä´N¬O»¡°Ê§@¤¤¸ê®Æ¿ýªº¦ì¸m­Y¶W¹L¸ê®Æ¿ý³Ì«á¤@µ§¸ê®Æ®É´N°±¤î°j°é±Ô­z¡A·íµM¡A¦b°j°é¤¤±Ô­z°õ¦æŪ¨ú¤@µ§¸ê®Æ¿ý¸ê®Æ«á¡Amysql_fetch_array()¨ç¼Æ·|¦Û°Ê±N§@¥Î¤¤¸ê®Æ¿ýªº¦ì¸m²¾¦Ü¤U¤@µ§¸ê®Æ¤W¡I
µ{¦¡½X²Ä14¦æ»P²Ä16¦æ¡G¬°¤FÂI¿ï¬Y¤@­Ó¤w¦s¦bªº°Q½×¶µ¥Ø¡u¥DÃD¡v¶W³sµ²«á¡A¥i¥H³sµ²¶i¤J¸Ó°Q½×¥DÃDªº¹ïÀ³°Q½×ºô­¶¡]join.php¡^¡A©Ò¥H§Ú­Ì¥²¶·§Q¥Î¥D¼ÐÃD¸ê®Æªí¤¤¡y¥D½s¸¹¡zªºÄæ¦ì¸ê®Æ¨Ó«Ø¥ß¶W³sµ²¡A·íµ{¦¡ºô­¶°õ¦æ«á¡A§Ú­ÌÀ˵øºô­¶ªº­ì©l½X±NÀò±o¤U¦Cµ²ªG¡G
  1. <TD width="50%" bgcolor="#E8FFFF"><A HREF=join.php?ID=1>
  2.    <font size="2">
  3.    ´ú¸Õ</font></A></TD>
½Æ»s¥N½X
¬°¤FÅý¸û±ßµoªíªº°Q½×¥DÃD¦b¦Cªí®É¯à±Æ¦bºô­¶ªº¤W¤è¡A¦]¦¹¡A§Ú­Ì¦b¶}±Ò¸ê®ÆªíªºSQL±Ô­z¤¤¡A°£¤F«ü©w¶}±Òªº¸ê®Æªí¬°MainTitle¡]¥D¼ÐÃD¡^¥~¡AÁÙ¥[¤W¤F¡uOrder By µo¨¥¤é´Á Desc¡vªº±Æ§Ç»yªk±Ô­z¡A¤]´N¬O¨Ì·Ó¡yµo¨¥¤é´Á¡zÄæ¦ìªº¸ê®Æ¤º®e°µ»¼´î±Æ§Ç¡C
  1. //«Ø¥ß¬d¸ß¦r¦ê
  2. $SQL="Select * From MainTitle Order By µo¨¥¤é´Á Desc";
  3. //±N¦^¶Çµ²ªG¦s©ñ©óÅܼƤ¤
  4. $datalist=mysql_query($SQL);
½Æ»s¥N½X
¤ß¦w¡A¥­¦w   
µoªí¥ô¦óµL·N¸qªº·PÁ©ÎÄé¤ô¤å³¹¤@«ß¬å,¬Ã±¤±b¸¹,½Ð¸Ô¾\ª©³W!!

index.php
  1. <?
  2. //³sµ²MySQL Server
  3.     $conn = mysql_connect("localhost", "root", "12345a");
  4. //¿ï¾Ü¸ê®Æ®w
  5.     mysql_select_db("BBS", $conn);
  6. //«ü©w´£¨ú¸ê®Æªº®Õ¹ï¦r¤¸ªí
  7.     mysql_query("set character set big5");
  8. //«Ø¥ß¬d¸ß¦r¦ê
  9. $SQL="Select * From MainTitle Order By µo¨¥¤é´Á Desc";
  10. //±N¦^¶Çµ²ªG¦s©ñ©óÅܼƤ¤
  11. $datalist=mysql_query($SQL);
  12. ?>

  13. <HTML>
  14. <head><title>PHP¾Ç²ß°Q½×°Ï</title>
  15. <meta http-equiv="Content-Type" content="text/html; charset=big5">
  16. </head>
  17. <BODY>
  18. <h2 Align="Center"><img border="0" src="bbs.gif"></h2>
  19. <TABLE Border=0 Cellspacing=5 width="100%">  
  20. <TR BgColor=#00FFFF>  
  21. <TD align="center" bgcolor="#0066FF" width="20%">
  22. <font size="2" color="#FFFFFF">¤é´Á/®É¶¡</font></TD>
  23. <TD NoWrapP align="center" bgcolor="#0066FF" width="20%">
  24. <font size="2" color="#FFFFFF">°Q½×µo°_¤H</font></TD>
  25. <TD align="center" bgcolor="#0066FF" width="50%">
  26. <font size="2" color="#FFFFFF">¥DÃD</font></TD>
  27. <TD align="center" bgcolor="#0066FF" width="10%">
  28. <font size="2" color="#FFFFFF">¦^À³½g¼Æ</font></TD></TR>

  29. <?
  30. //±N¸ê®Æ¿ýÂà´«¬°Äæ¦ì°}¦C¶°¦X
  31. While (($fielddatas=mysql_fetch_array($datalist)))
  32. {
  33. ?>
  34. <TR Valign=TOP>
  35. <TD NoWrap width="20%" bgcolor="#E8FFFF">
  36. <p align="center"><font size="2">
  37. <?=$fielddatas["µo¨¥¤é´Á"];?></font></TD>
  38. <TD width="20%" bgcolor="#E8FFFF">
  39. <p align="center"><font size="2">
  40. <?=$fielddatas["©m¦W"];?></font></TD>
  41. <TD width="50%" bgcolor="#E8FFFF">
  42. <A HREF=join.php?ID=<?=$fielddatas["¥D½s¸¹"];?>>
  43. <font size="2">
  44. <?=$fielddatas["¥DÃD"];?></font></A></TD>
  45. <TD width="10%" bgcolor="#E8FFFF">
  46. <p align="center"><font size="2">
  47. <?=$fielddatas["½g¼Æ"];?></font></TD>
  48. </TR>
  49. <?
  50. }
  51. ?>
  52. </TABLE>

  53. <TABLE Width="100%"><TR><TD Align=Center bgcolor=#000080>
  54. <B><font color="#FFFFFF" size="2">§Ú¦³·s°ÝÃD­n°Q½×</font></B>
  55. </TD></TR></TABLE>
  56. <CENTER>
  57. <FORM Action=addnew.php Method=POST>
  58. <TABLE Border="1" bgcolor="#FFCC66" bordercolor="#FF9933" cellspacing="0">
  59. <TR><TD><font size="2">©m¦W¡G</font></TD>
  60. <TD><font size="2"><INPUT Type="text" Size="30" Name="©m¦W"></font></TD></TR>
  61. <TR><TD><font size="2">Email¡G</font></TD>
  62. <TD><font size="2"><INPUT Type="text" Size="30" Name="Email">
  63.   </font>
  64. </TD></TR>
  65. <TR><TD><font size="2">¥DÃD¡G</font></TD>
  66. <TD><font size="2"><INPUT Type="text" Size="60" Name="¥DÃD">
  67.   </font>
  68. </TD></TR>
  69. <TR><TD><font size="2">¤º®e¡G</font></TD>
  70. <TD><font size="2"><TEXTAREA Name="¤º®e" Rows="8" Cols="60">
  71. </TEXTAREA></font></TD></TR>
  72. </TABLE>
  73. <INPUT Type="submit" Value="°e¥X°Q½×¥DÃD">
  74. </FORM>
  75. </CENTER>
  76. </BODY>
  77. </HTML>
½Æ»s¥N½X
¤ß¦w¡A¥­¦w   
µoªí¥ô¦óµL·N¸qªº·PÁ©ÎÄé¤ô¤å³¹¤@«ß¬å,¬Ã±¤±b¸¹,½Ð¸Ô¾\ª©³W!!

TOP

·s¥DÃD¸ê®Æ³B²zµ{¦¡
¤§«e½Í¨ì¡G¦pªG·Q­nµoªí·sªº°Q½×¶µ¥Ø¡A¥iª½±µ¦bµ{¦¡ºô­¶¡]index.php¡^¤U¤èªºµo¨¥ªí³æ¤¤¿é¤J¸ê®Æ¨Ó«Ø¥ß·sªº°Q½×¥DÃD¡A¦ý¬O¡Aindex.phpºô­¶µ{¦¡¨Ã¤£­t³d³B²z·s°Q½×¥DÃD«Ø¥ß»P¼g¤J¸ê®Æ®w¤¤ªº¥ô°È¡A¦Ó¬O±N¬ÛÃöªº¸ê®Æ©ó¶ñ¼g§¹«ö¤U¡y°e¥X°Q½×¥DÃD¡z«ö¶s«á¥æ¥Ñaddnew.phpµ{¦¡¨Ó³B²z¡C

  • ¥»·s¥DÃD³B²zµ{¦¡addnew.php·s¼W¸ê®Æ¿ý¬O¨Ï¥ÎSQL»y¨¥ªºInsert Into©R¥O±Ô­z¡C
  • §¹¦¨·s¼W¸ê®Æ¿ý¼g¤J¸ê®Æ®w«á¡A°O±o±Nºô­¶³sµ²Âà¦V¦^index.phpµ{¦¡ºô­¶¡A§_«hÂsÄýªÌ©Ò¨£¨ìªº±N¥u¬O¤@­ÓªÅ¥Õºô­¶¡C


addnew.php
  1. <?
  2. //³sµ²MySQL Server
  3.     $conn = mysql_connect("localhost", "root", "12345a");
  4. //¿ï¾Ü¸ê®Æ®w
  5.     mysql_select_db("BBS", $conn);
  6. //«ü©w´£¨ú¸ê®Æªº®Õ¹ï¦r¤¸ªí
  7.     mysql_query("set character set big5");

  8. //±N³æ¤Þ¸¹¸m´«¬°Âù¤Þ¸¹
  9. Function chgStr($data)
  10. {
  11.    $chgStr = "'" . str_replace("'", "''", $data) . "'";
  12.    return $chgStr;
  13. }

  14. //±N¸ê®Æ¼g¤J¸ê®Æ®w
  15. $sql = "Insert Into maintitle (©m¦W, Email, ¥DÃD, ¤º®e, ½g¼Æ, µo¨¥¤é´Á) Values (";
  16. $sql = $sql . chgStr($_REQUEST["©m¦W"]) . ",";
  17. $sql = $sql . chgStr($_REQUEST["Email"]) . ",";
  18. $sql = $sql . chgStr($_REQUEST["¥DÃD"]) . ",";
  19. $sql = $sql . chgStr(nl2br($_REQUEST["¤º®e"])) . ",";
  20. $sql = $sql . 0 . ",'";
  21. $sql = $sql . date("Y-m-j H:i:s") . "')";
  22. mysql_query($sql);

  23. header("Location: index.php");
  24. ?>
½Æ»s¥N½X
¤ß¦w¡A¥­¦w   
µoªí¥ô¦óµL·N¸qªº·PÁ©ÎÄé¤ô¤å³¹¤@«ß¬å,¬Ã±¤±b¸¹,½Ð¸Ô¾\ª©³W!!

TOP

        ÀR«ä¦Û¦b : ¨C¤ÑµL©Ò¨Æ¨Æ¡A¬O¤H¥Íªº®ø¶OªÌ¡A¿n·¥¡B¦³¥Î¤~¬O¤H¥Íªº³Ð³yªÌ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD