[請益] 表單、資料庫

看板PHP作者 (MOMO‧小光)時間17年前 (2008/03/19 21:03), 編輯推噓4(408)
留言12則, 3人參與, 最新討論串1/2 (看更多)
請問各位大大 我想要把在兩格表單裡的資料上傳到資料庫裡面 這樣對嗎? HTML <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=big5"> <meta name="GENERATOR" content="Microsoft FrontPage 4.0"> <meta name="ProgId" content="FrontPage.Editor.Document"> <title> test </title> </head> <body> <form name="forml" method="get" action="ch3-7-1.php"> <p>姓名: <input name="name" type="text" id="name"> </p> <p>學校: <input name="school" type="text" id="school"> </p> <p> <input type="submit" name="Submit" value="送出"> <input type="reset" name="Submit2" value="重設"> </p> </from> </body> </html> 這是ch3-7-1.php <?php $link = mysql_connect("■■■", "■■■", "■■■") or die("無法連接資料庫 "); mysql_select_db("test") or die("無法選擇資料庫"); $query = "INSERT INTO test (sch_id, name, score) VALUES ('00001','$name', '$school')"; mysql_query($query) or die("無法送出" . mysql_error( )); ?> 這樣可以成功嗎? 能不能直接從資料庫看到輸入的值? 如果輸入很多次 能不能按照順序讓sch_id從00001 > 00002 > 00003 ? 先感謝大大了~ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.134.31.123 ※ 編輯: momogen 來自: 220.134.31.123 (03/19 21:17)

03/19 21:33, , 1F
不能成功,你php程式沒去接收到get發出的資料
03/19 21:33, 1F

03/19 21:36, , 2F
請問能指導一下該怎麼接收嗎 感謝>"<
03/19 21:36, 2F

03/19 22:29, , 3F
$_GET["name"]
03/19 22:29, 3F

03/19 22:31, , 4F
sch_id 是主鍵嗎? 可以設自動遞增
03/19 22:31, 4F

03/19 22:52, , 5F
請問什麼是主鍵..? 自動遞增..?
03/19 22:52, 5F

03/19 23:10, , 7F
如果你有MySQL的GUI的管理介面 這些動作會比較容易做到
03/19 23:10, 7F

03/19 23:19, , 8F
嗯.. sch_id是主鍵 但是要怎麼讓它自動遞增呢? 感謝
03/19 23:19, 8F

03/19 23:21, , 9F
另外 $school = $_GET ["school"] 這樣寫對嗎?
03/19 23:21, 9F

03/19 23:22, , 10F
它有跳出錯誤訊息>"<
03/19 23:22, 10F

03/19 23:30, , 11F
你可以用phpMyAdmin的"附加"的auto_increment來設定
03/19 23:30, 11F

03/19 23:32, , 12F
自動遞增
03/19 23:32, 12F
文章代碼(AID): #17uGyBzt (PHP)
文章代碼(AID): #17uGyBzt (PHP)