我现在正面临一个挑战。
我有一个返回页,如果我通过单选按钮选择了第一行,我想改变我的订单历史表中的历史状态 "DONE"
至 "RETURN PENDING"
. 我这样做的原因是运行一个查询,只显示历史记录和状态值 "DONE"
.
下面是我正在使用的代码:
<?php
$db = mysqli_connect('localhost','root','','customercaremodule');
date_default_timezone_set('Asia/Kuala_Lumpur');
$FBdate = date("Y-m-d H:i:s");
$sql = "SELECT p.product_id ,p.product_name , p.price, p.product_description, o.history_id ,o.qty , o.subtotal, o.history_datetime , o.history_status FROM product p, orderhistory o where o.product_id = p.product_id AND o.history_status = 'DONE'";
$result=mysqli_query($db,$sql);
$Cntsql = "SELECT count(return_id) AS total FROM retrn";
$res = mysqli_query($db,$Cntsql);
$value = mysqli_fetch_assoc($res);
$num = $value['total'];
if (isset($_POST['submitbuttonform']))
{
$return_id = $num+1;
$return_status = 'PENDING';
$return_reason = $_POST['reasonselected'];
$return_option = $_POST['returnoption'];
$return_datetime = $FBdate;
$history_id = $_POST['selectitemradio'];
$history_status = "UPDATE orderhistory SET history_status = 'RETURN PENDING'";
$sql = "INSERT INTO `retrn`(`return_id`, `return_status`, `return_reason`, `return_option`, `return_datetime`, `history_id`) VALUES ('$return_id','$return_status','$return_reason','$return_option','$return_datetime','$history_id')";
$sql = "INSERT INTO 'orderhistory'('history_status') VALUES ('$history_status')";
$result=mysqli_query($db,$sql);
订单历史记录表
返回页布局
1条答案
按热度按时间vzgqcmou1#
从代码$history\u id=$\u post['selectitemroid'];我想你是从页面上得到历史记录的。
所以可以在where子句中使用history\u id。现在只更新选定的行。
update orderhistory set history\u status='return pending'其中history\u id=$history\u id