简体   繁体   English

检查值并将其插入到现有行的列中

[英]Checking values and inserting in to column of existing row

At the moment I am working on a form that on submit goes to a payment gateway to allow the user to pay for the event they registered for. 目前,我正在处理一个表单,该表单在提交后会转到付款网关,以允许用户为他们注册的事件付款。 The payments and form are working correctly. 付款和表格工作正常。

I store the generated merchant session ID and other values in to my database (mySQL) when the user goes to make a payment. 当用户付款时,我将生成的商人会话ID和其他值存储到我的数据库(mySQL)中。

The problem I am having is how do I check that once payment is made and the payment site returns the values that the merchant session ID is the same and update the payment status column in that existing row. 我遇到的问题是,如何检查付款后付款站点返回的商人会话ID相同的值,并更新该行中的付款状态列。

I'm really not sure how I do this with php and I think that is where the problem lies. 我真的不知道如何用php来做到这一点,我认为这就是问题所在。 I have been googling but to no avail.. 我一直在谷歌搜索,但无济于事。

What I've tried has been along the lines of: 我尝试过的方法如下:

$merchant = $_GET['ms'];
$status = $_GET['ec'];
if ($merchant == 'session')
{
$sql ="UPDATE $tbl_name SET paystatus='$status' WHERE session = '$merchant'";
}

I'm not sure if I need to specify to update the column of that exact row where merchant == session or how. 我不确定是否需要指定更新商家==会话或操作方式的确切行的列。

$merchant = $_GET['ms'];//merchant
$status = $_GET['ec'];//error code
$query = "SELECT `merchant` FROM `tbl` WHERE `merchant` = '".$merchant."'";//select merchant column where merchant variable is in your table
$result = mysqli_query($query); //query
if ($result&&$status!=0)//if query succeeds and error != 0
{
$sql ="UPDATE $tbl_name SET paystatus='".$status."' WHERE session = '".$merchant."'";//update
$doquery = mysqli_query($sql);//query
}

This should do what you want. 这应该做您想要的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM