更新数组中的表值

时间:2019-04-15 04:11:31

标签: php arrays mysqli

我有一个表,然后我想更新数组中的表值。使用相应的id。我正在使用REPLACE INTO,但所有行都会每次更新。所以我不要。如果该交易ID的数组中的任何值发生更改,我只有更新。(对不起,我的语言不好) 看我的例子

$tbtransaction = array(
    array(
        "TransactionID" => 16,
        "VoucherType" => "Cash Payment",
        "AccName" => "OFFICE EXPENSE",
        "Particulars" => "CASH ACCOUNT",
        "Debit" => 2000,
        "Credit" => 50,
    ),
    array(
        "TransactionID" => 17,
        "VoucherType" => "Cash Payment",
        "AccName" => "OFFICE EXPENSE",
        "Particulars" => "CASH ACCOUNT",
        "Debit" => 1250,
        "Credit" => 350,
    ),
    array(
        "TransactionID" => 18
        ,
        "VoucherType" => "Bank Payment",
        "AccName" => "Simple EXPENSE",
        "Particulars" => "CASH ACCOUNT",
        "Debit" => 410,
        "Credit" => 0,
    ),
    array(
        "TransactionID" => 19,
        "VoucherType" => "Cash Payment",
        "AccName" => "OFFICE EXPENSE",
        "Particulars" => "CASH ACCOUNT",
        "Debit" => 2000,
        "Credit" => 0,
    ),
    array(
        "TransactionID" => 20,
        "VoucherType" => "Cash Payment",
        "AccName" => "OFFICE EXPENSE",
        "Particulars" => "CASH ACCOUNT",
        "Debit" => 25,
        "Credit" => 40,
    ),

);

交易表

TransactionID   VoucherType    AccName          Particulars    Debit  Credit
--------------------------------------------------------------------------------
16           Cash Payment   OFFICE EXPENSE     CASH ACCOUNT    2000     50
17           Cash Payment   OFFICE EXPENSE     CASH ACCOUNT    1250     300
18           BankPayment    OTHER EXPENSE      OTHER ACCOUNT   410      10
19           Cash Payment   TRAVEL EXPENSE     BANK ACCOUNT    300       0
20           Cash Payment   OFFICE EXPENSE     CASH ACCOUNT    25       40

0 个答案:

没有答案