[請益] 新手發問...

看板PHP作者 (皮)時間17年前 (2007/03/15 12:02), 編輯推噓0(002)
留言2則, 1人參與, 最新討論串1/2 (看更多)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "" rel="nofollow">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="" rel="nofollow">http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>測試</title> </head> <body> <form id="form1" name="form1" method="post" action="tt.php"> <table width="600" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="214"><input name="date" type="text" id="date" /></td> <td width="550"><select name="class" id="class"> <option value="測試一">測試一</option> <option value="測試二">測試二</option> </select> </td> </tr> <tr> <td><input name="id" type="text" id="id" /></td> <td>&nbsp;</td> </tr> <tr> <td><input type="submit" name="Submit" value="送出"/></td> <td>&nbsp;</td> </tr> </table> </form> <font size=3> <b> 結果顯示 </b> </font> <hr> <?php $ydate=$_POST["date"]; $yid=$_POST["id"]; $yclass=$_POST["class"]; $host="localhost"; $user="root"; $pass="password"; $database="student"; $link=mysql_connect($host,$user,$pass); $db=mysql_select_db($database,$link); if($yid == "100001") { $select_str="UPDATE class_01 Set 100001='$yclass' where date='$ydate'"; }else if($yid == "100002") { $select_str="UPDATE class_01 Set 100002='$yclass' where date='$ydate'"; }else if($yid == "100003") { $select_str="UPDATE class_01 Set 100003='$yclass' where date='$ydate'"; }else{ echo "無法新增<br>"; } ?> </body> </html> --------------抱歉寫的很長------------ 我試了好久, 都不知道為什麼不能update資料庫中的資料..... 請問我哪裡寫錯了嗎? 資料庫中有date, 100001, 100002, 100003三個欄位. 目標是在輸入date和號碼(100001, 100002 or 100003)及class之後 能修改某個date之下, 某個欄位的值. 謝謝~~ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 59.112.32.231

03/15 12:21, , 1F
只能說完全沒有POST的概念 也對PHP變數應用不了解
03/15 12:21, 1F

03/15 12:22, , 2F
少了個query動作吧
03/15 12:22, 2F
文章代碼(AID): #15-CLbNu (PHP)
文章代碼(AID): #15-CLbNu (PHP)