<!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> </td>
</tr>
<tr>
<td><input type="submit" name="Submit" value="送出"/></td>
<td> </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
03/15 12:21, 1F
→
03/15 12:22, , 2F
03/15 12:22, 2F
討論串 (同標題文章)
完整討論串 (本文為第 1 之 2 篇):
請益
0
2