在php页面中,一旦我们点击“提交”按钮,在数据库中我们正在保存订单id,其工作正常。。。。
php - 根据if else条件更新行值-LMLPHP
要求:
如果付款是“货到付款”,则我希望将订单id保存在“awb_type:COD”行中。。。。否则在“awb_type:PPD”行。。。。
php - 根据if else条件更新行值-LMLPHP
这是完整的代码,track.php:https://pastebin.com/zLjpee7A,call.php:https://pastebin.com/4LkcxTYE
但订单在表中更新了两次-PPD中的一行和COD中的一行
php - 根据if else条件更新行值-LMLPHP
如果你需要更多的信息请告诉我。。。。
更新2:
现在我尝试了下面的代码,但是无论是payment_type,它只保存在awb_type列:PPD rows。。。。

$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);
}

最佳答案

在我没有用订单id绑定付款类型之前,下面的代码对我有效:

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);

09-30 13:42
查看更多