我有簡單的付款方式,它包括voucher_id
,customer_id
,amount
,payment_type
,transaction_type
和date
。php mysql(插入查詢)
Transaction_type的取款和存款。
我的數據庫表不應該包含「金額」列。它有信用卡和借記欄。在這種情況下,如果INSERT
的金額爲debit
列,如果交易type ="Withdraws"
的INSERT
金額爲信用列Transaction_type ="Deposits"
。
當我INSERT
數據表顯示:
列數在列不匹配值計數1
因爲,表中有借方和貸方列。但是我的表單有一列,名字就是金額。如何插入此查詢來理清我的問題。
<?php
// save data if form is submitted
if(isset($_POST['submitted'])){
// catch data
$voucher_numebr = $_POST['voucher_numebr'];
$member_id = $_POST['member_id'];
$amount = $_POST['amount'];
$acc_type = $_POST['acc_type'];
$payment_type = $_POST['payment_type'];
$discription = $_POST['discription'];
$created = date("Y-m-d H:i:s");
// $balance = $_POST['balance'];
$tranaction_type = $_POST['tranaction_type'];
$balance="NOT DEFINE";
//insert to the tbl_customer_account
if($tranaction_type == "Withdrawls."){
//echo "1";
$sql ='INSERT INTO tbl_customer_account VALUES(NULL,"'.$voucher_numebr.'","'.$member_id.'","'.$amount.'","'.$acc_type.'","'.$payment_type.'","'.$discription.'","'.$created.'","'.$tranaction_type.'","'.$balance.'")';
}
else{
$sql ='INSERT INTO tbl_customer_account VALUES(NULL,"'.$voucher_numebr.'","'.$member_id.'","'.$amount.'","'.$acc_type.'","'.$payment_type.'","'.$discription.'","'.$created.'")';
}
//else{
//}
mysql_query($sql, $conn) or die(mysql_error());
echo 'form submitted';
echo '<br />';
echo mysql_affected_rows(); die();
}
?>
你能分享一些代碼嗎? – shmosel
請幫我..這是我的最後一個項目。 – user3669821