我想請教一下我的PHP代碼..
我'做一些陣列編碼,但是當我提出我的數據庫我的數據,是將顯示一個數組該「說明」和「數量」一欄..
我用mysql .. 下面是我的陣列編碼..MySQL的數據將顯示在表列「陣列」
$item = array(
'item_description' => '',
'price' => '',
'qty' => '',
'amount' => '',
);
foreach ($item as $key => $value){
$item_description = $_POST['item_description'][$key];
$price = $_POST['price'][$key];
$qty = $_POST['qty'][$key];
$amount = $_POST['amount'][$key];}
}
這是我的插入查詢。
$sql1="INSERT INTO payment_item (payment_id, payment_item_id, item_description, price, qty, amount)
VALUES
('$last_insert_payment_id','NULL','$_POST[item_description]','$_POST[price]','$_POST[qty]','$_POST[amount]')";
這是我的形式:
<form>
<h1>Payment Item</h1>
Payment ID :<input id="payment_id" name="payment_id" type="text"><br>
<input type="button" value="Add Row" onClick="addRow('tableID')"/>
<input type="button" value="Delete Row" onClick="deleteRow('tableID')"/>
<table class="table" bgcolor="#CCCCCC">
<thead>
<tr>
<td></td>
<td><center>Item Description</center></td>
<td><center>Price (RM)</center></td>
<td><center>Month</center></td>
<td><center>Amount (RM)</center></td>
</tr>
</thead>
<tbody id="tableID">
<tr>
<td><input type="checkbox" name="chk"></td>
<td>
<select name="item_description">
<option value="deposit">Deposit</option>
<option value="rental">Rental</option>
<option value="stamp">Stamp Duty</option>
<option value="process">Process Fee</option>
<option value="ap">AP</option>
</select>
</td>
<td><input id="price" name="price" type="text"></td>
<td><input id="month" name="qty" type="text"></td>
<td><input id="amount" name="amount" type="text"></td>
</tr>
</tbody>
</table>
<input name="submit" type="submit" value="Submit">
<input name="reset" type="reset" value="Reset">
</form>
我'對不起,我英文不好的語言..
但我真的需要從別人的任何幫助這個..
謝謝。
一個'的var_dump($ _ POST)的每個變量做
'應該告訴你爲什麼發生這種情況。 –
某處,然後你將數組轉換爲字符串。如果你將一個數組轉換爲一個字符串,它將轉換爲「Array」。試着弄清楚爲什麼發生這種情況。 – Corbin
顯示你的插入查詢。 – Norse