当 dhtmlx 网格列 select 选项更改时需要另一个数据库值更新

Need another database value updated when dhtmlxgrid column select option changes

我正在使用 dhtmlxgrid 向能够编辑行单元格数据的用户显示 MySQL 数据库信息。一列 productionstage 显示为组合框列,可以将值更改为 Staged Done。这完美地更新了 DB table。但是,我需要检查 productionstage 列的值以测试 Staged Done 值。如果 productionstage 设置为该值,我需要在同一个 table 中的另一列 stagestatus 也将其值更新为 Production。最好不要让 DB table 中的 stagestatus 列成为最终用户可查看的列,而是在后端触发。

感谢所有帮助。谢谢!

我的代码:

//update row
$sql =  "UPDATE invoices SET editby='".$editBy."', editpage='".$editPage."', serverip='".$serverIp."', ip='".$Ip."',floornotes='".$_GET["floornotes"]."',productionstage='".$_GET["productionstage"]."' where id=".$_GET["gr_id"]."'";
$res = mysqli_query($sql);


if (($_GET['productionstage']) == 'Staged Done' ) {
    //update stagestatus from 'Scheduled' to Production if moved to 'Staged Done' in Glass Prep.
$sql1 = "UPDATE invoices SET stagestatus = 'Production') WHERE id=".$_GET["gr_id"]."'";
$res1 = mysqli_query($sql1);

}

注意::我知道以前的程序员使用的现有方法将脚本暴露给 SQL 注入攻击 - 我还将更新此脚本以使用准备好的语句...谢谢!

所以我一定是代码中某处有错误。经过一些测试和编辑,以下代码解决了这个问题(是的,dhtmlxgrid 可以为每个网格处理多个 UPDATE 语句)。

解决方案:

    //update row
$sql =  "UPDATE invoices SET editby='".$editBy."', editpage='".$editPage."', serverip='".$serverIp."', ip='".$Ip."',floornotes='".$_GET["floornotes"]."',productionstage='".$_GET["productionstage"]."' where id=".$_GET["gr_id"]."";
$res = mysqli_query($sql);



if (($_GET['productionstage']) == 'Staged Done' ) {


    $sql1 = "UPDATE invoices SET stagestatus = 'Production' WHERE id=".$_GET["gr_id"]."";
    $res1 = mysqli_query($sql1);

} else {

    print("<action type='error'>SQL query error</action>");

}

请注意:我的下一步是使用准备好的语句进一步更新代码,使脚本更安全。

谢谢!