gpt4 book ai didi

javascript - 我怎样才能分别更新php查询几个不同的值?

转载 作者:行者123 更新时间:2023-11-29 19:26:03 25 4
gpt4 key购买 nike

我必须分别修改/更新两个不同的输入值。问题在于,它们$_GET不会单独更新相同的值,而且它们都获得输入更新查询执行的值(因为请求值相同。。我知道)。我的问题是,如何在查询中获得不相同的值时分别更新它们。我必须更改$_REQUEST还是必须做出if()语句? PS我的代码示例都在一起,并且一点点关闭,但不是在真正的PHP失败

<td class="stock" id="'.$r["product_id"].'">'.STRIPSLASHES($r["product_in_stock"]).'</td>
<td class="test" id="'.$r["product_id"].'"><font size=+2><b>'.$r["product_s_desc"].'</b></font></td>


<script>
var x;
var h = 0; // blur fires multiple times, use h to count and fire once
var url = 'up.php';

$(".test").on('click', function(d) {
d.stopPropagation();
var x = $(d.target);
x.html('<input id="edit" style="width: 40px;" value="'+x.text()+'">');
var this_id = x.context.id;

$("#edit").on('blur', function(d) {
if (h < 1) {
h = h+1;
d.stopPropagation();

$(d.target.parentElement).text(d.target.value);

$.get(url, {id: this_id, value: d.target.value})
.done(function(d){ if(d == undefined || d != 1) { alert('Something went wrong, check your data and results. '+d);}})

$("#edit").off('blur');
}

return false;
});
h = 0;
});
</script>

<script>
var x;
var h = 0; // blur fires multiple times, use h to count and fire once
var url = 'up.php';

$(".stock").on('click', function(d) {
d.stopPropagation();
var x = $(d.target);
x.html('<input id="edit2" style="width: 40px;" value="'+x.text()+'">');
var this_id = x.context.id;

$("#edit2").on('blur', function(d) {
if (h < 1) {
h = h+1;
d.stopPropagation();

$(d.target.parentElement).text(d.target.value);

$.get(url, {id: this_id, value: d.target.value})
.done(function(d){ if(d == undefined || d != 1) { alert('Something went wrong, check your data and results. '+d);}})
.fail(function(d){ alert('error');});
$("#edit2").off('blur');
}

return false;
});
h = 0;
});
</script>


require_once('db.php');


$q2= 'UPDATE prestashop.ps_stock_available SET quantity = %d WHERE id_product = %d';
$q= 'UPDATE prestashop.ps_product SET location = '%s' WHERE id_product = %d';



$sql = sprintf($q, $_REQUEST['value'], $_REQUEST['id']);
$sql2 = sprintf($q2, $_REQUEST['value'], $_REQUEST['id']);

$rs=$ib->exec($sql);
$rs=$ib->exec($sql2);
if (PEAR::isError($rs)) throw new Exception ("DB Request: ". $rs->getMessage());

die("1"); // exit and return 1 on success

} catch (Exception $e) {
print $e->getMessage();
}

最佳答案

我知道这是一种不安全的方法,但是我使用了不同的请求值和if(empty)

关于javascript - 我怎样才能分别更新php查询几个不同的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42146495/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com