我想更新两个表,名为: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'];' - 那么您会期待什么? –