我想更新兩個表,名爲:routing和routing_has_work_center如何更新mysql中的2個表?
在路由表中,用戶可以在routing_has_work_center表中編輯描述,用戶可以編輯production_hour。
<?php
session_start();
// include a php file that contains the common database connection codes
include ("dbFunctions.php");
//retrieve computer details from the textarea on the previous page
$description = $_POST['description'];
$production_hour=$_POST['$production_hour'];
//retrieve id from the hidden form field of the previous page
$theID = $_POST['routing_id'];
$msg = "";
//build a query to update the table
//update the record with the details from the form
$queryUpdate = "UPDATE routing SET description='$description' WHERE routing_id = $theID";
//execute the query
$resultUpdate = mysqli_query($link, $queryUpdate) or die(mysqli_error($link));
//if statement to check whether the update is successful
//store the success or error message into variable $msg
if ($resultUpdate) {
$msg = "Record updated successfully!";
} else {
$msg = "Record not updated!";
}
?>
我有這樣上面的代碼,但是當我更新了生產時間,它仍然是相同的,並在routing_has_work_center數據庫沒有更新。
我是否必須在查詢中添加其他內容?
您是否聽說過SQL注入? –
你需要[與Bobby Tables的父母談談](http://bobby-tables.com/)。 –
發佈代碼中只有一行使用'production_hour' - 即'$ production_hour = $ _ POST ['$ production_hour'];' - 那麼您會期待什麼? –