我試圖讓這個工作幾個小時了,我認爲它與我有一個$ _GET ['ID']的事實有關;第一個腳本,但林不知道:SQL不更新行
腳本1(FORM):
<?php
\t require_once('db_access.php');
\t $editID = $_GET['id'];
$query = mysql_query("SELECT * from routes where id = '".$editID."'");
$row = mysql_fetch_assoc($query);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Form Edit Data</title>
</head>
<body>
<table border=1>
<tr>
<td align=center>Route Edit Data</td>
</tr>
<tr>
<td>
<table>
<form method="post" action="complete_edit.php">
<tr>
<td>ID #</td>
<td>
<input type="hidden" name="formid" value="<?php echo $row['id'] ?>">
</td>
</tr>
<tr>
<td>Route Name</td>
<td>
<input type="text" name="route_title" size="40"
value="<?php echo $row['route_title']?>">
</td>
</tr>
<tr>
<td>Total Price</td>
<td>
<input type="text" name="total_price" size="40"
value="<?php echo $row['total_price']?>">
</td>
</tr>
<tr>
<td>Down Payment</td>
<td>
<input type="text" name="down_payment" size="40"
value="<?php echo $row['down_payment']?>">
</td>
</tr>
<tr>
<td>Weekly Net</td>
<td>
<input type="text" name="weekly_net" size="40"
value="<?php echo $row['weekly_net']?>">
</td>
</tr>
<tr>
<td>Location</td>
<td>
<input type="text" name="location" size="40"
value="<?php echo $row['location']?>">
</td>
</tr>
<tr>
<td>Remarks</td>
<td>
<input type="text" name="remarks" size="40"
value="<?php echo $row['remarks']?>">
</td>
</tr>
<tr>
<td align="right">
<input type="submit"
name="submit value" value="Edit">
</td>
</tr>
</form>
</table>
</td>
</tr>
</table>
</body>
</html>
SCRIPT 2(加工):
<?php
\t \t $id = $_POSt['formid'];
\t \t $editroute = $_POST['route_title'];
\t $editprice = $_POST['total_price'];
\t $editdownpay = $_POST['down_payment'];
\t $editweeklynet = $_POST['weekly_net'];
\t $editlocation = $_POST['location'];
\t $editremarks = $_POST['remarks'];
\t $query = "UPDATE routes SET id = '$id', route_title = '$editroute', total_price = '$editprice', down_payment = '$editdownpay', weekly_net = '$editweeklynet', location = '$editlocation', remarks = '$editremarks' WHERE id = '$id'";
\t header('Location:index.php');
?> \t \t
Th Ë第一大量的代碼是我的形式放置,第二個是在處理髮生 感謝您的幫助的人:) 亞歷
'$ _POSt ['formid'];'應該''_ _POST [' formid'];'也不要相信用戶輸入,但這似乎不會去DB,所以也許你只是測試? – chris85
我已驗證所有POST數據正在處理complete_edit.php但沒有更新? –