在 php 页面中,一旦我们点击“提交”按钮,我们就会在数据库中保存订单 ID,它工作正常......
要求:
如果付款方式为“货到付款”,那么我想将订单 ID 保存在 “awb_type : COD” 行中......否则保存在 “awb_type : PPD” 中> 行....
这是完整的代码,track.php:https://pastebin.com/zLjpee7A ,call.php:https://pastebin.com/4LkcxTYE
但是订单在表中更新了两次 - PPD 中的一行和 COD 中的一行
如果您需要更多信息,请告诉我......
更新2:
现在我尝试了下面的代码,但无论 payment_type 是什么,它仅保存在 awb_type 列中:PPD 行....
$sqlc = "select * from ecomexpress_awb WHERE status='unused' AND awb_type='COD' limit 1";
$resultc = $db_handle->runSelectQuery($sqlc);
$sqld = "select * from ecomexpress_awb WHERE status='unused' AND awb_type='PPD' limit 1";
$resultd = $db_handle->runSelectQuery($sqld);
$payment_type='';
$sqlg="SELECT * FROM do_order where payment_type='".$payment_type."'";
$resultg = $db_handle->runSelectQuery($sqlg);
if($payment_type=="Cash on delivery")
{
$awb = $resultc[0]['awb'];
$sqle = "update ecomexpress_awb set orderid = '".$order_id."',status='used' WHERE awb ='".$awb."' limit 1";
$resulte = $db_handle->runSelectQuery($sqle);
}
else
{
$awba = $resultd[0]['awb'];
$sqlf = "update ecomexpress_awb set orderid = '".$order_id."',status='used' WHERE awb ='".$awba."' limit 1";
$resultf = $db_handle->runSelectQuery($sqlf);
}
最佳答案
在我没有将 payment_type 与 order_id 绑定(bind)之前,以下代码对我有用:
if(isset($_POST['order_id']) && $_POST['order_id']!='')
{
$order_id = $_POST['order_id'];
$payment_type=$_POST['payment_type'];
$sqlg="SELECT * FROM do_order where payment_type='".$payment_type."'";
$resultg = $db_handle->runSelectQuery($sqlg);
if($payment_type=="Cash on delivery")
{
$sqlc = "select * from ecomexpress_awb WHERE status='unused' AND awb_type='COD' limit 1";
}
else
{
$sqlc = "select * from ecomexpress_awb WHERE status='unused' AND awb_type='PPD' limit 1";
}
$resultc = $db_handle->runSelectQuery($sqlc);
关于php - 根据 if else 条件更新行值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53447047/