我正在使用帶有一些輸入字段的小表來發布頁面。 我想檢索用戶填寫特定儀器編號的數據。檢索動態發佈值
我的代碼
<form name="frmDeposit" action="paymentdeposited.php" method="post">
<table cellpadding="0" cellspacing="0" border="0" id="table" class="tinytable" style="width:700px;">
<thead>
<tr>
<th><h3>Email</h3></th>
<th><h3>Amount Paid</h3></th>
<th><h3>Instrument Type</h3></th>
<th><h3>Instrument No.</h3></th>
<th><h3>Date Paid</h3></th>
<th class="nosort"><h3>Date Deposited</h3></th>
<th class="nosort"><h3>Bank Name</h3></th>
<th class="nosort"><h3>Slip No.</h3></th>
<th class="nosort"><h3>Submit</h3></th>
</tr>
</thead>
<tbody>
<?php
foreach($paymentsdeposited as $paymentdeposited)
{
?>
<tr>
<td><?php echo $paymentdeposited[email];?></td>
<td><?php echo $paymentdeposited[amount];?></td>
<td><?php echo $paymentdeposited[instrument];?></td>
<td><?php echo $paymentdeposited[instrumentnumber];?></td>
<td><?php echo $paymentdeposited[dated];?></td>
<td><input type="text" name="txtDateDeposited_<?php echo $paymentdeposited[pk_paymentinstrumentid];?>" class="field date-pick"/></td>
<td><input type="text" name="txtBankName_<?php echo $paymentdeposited[pk_paymentinstrumentid];?>" class="field"/></td>
<td><input type="text" name="txtSlipNo_<?php echo $paymentdeposited[pk_paymentinstrumentid];?>" class="field"/><input type="hidden" name="txtPaymentInstrumentNo_<?php echo $paymentdeposited[pk_paymentinstrumentid];?>" value="<?php echo $paymentdeposited[pk_paymentinstrumentid];?>" class="field"/></td>
<td><input type="submit" name="btnSubmit1" value="Submit"/></td>
</tr>
<?php
}
?>
</tbody>
</table>
的print_r的命令輸出
Array
(
[txtDateDeposited_57] => 2010-05-07
[txtBankName_57] => pnb
[txtSlipNo_57] => 121
[txtPaymentInstrumentNo_57] => 57
[btnSubmit1] => Submit
[txtDateDeposited_51] =>
[txtBankName_51] =>
[txtSlipNo_51] =>
[txtPaymentInstrumentNo_51] => 51
[txtDateDeposited_52] =>
[txtBankName_52] =>
[txtSlipNo_52] =>
[txtPaymentInstrumentNo_52] => 52
[txtDateDeposited_45] =>
[txtBankName_45] =>
[txtSlipNo_45] =>
[txtPaymentInstrumentNo_45] => 45
[txtDateDeposited_47] =>
[txtBankName_47] =>
[txtSlipNo_47] =>
[txtPaymentInstrumentNo_47] => 47
)
我要檢索的值,爲此他已經進入價值ID 57。但我無法構建檢索此值的邏輯。我想讓它變得動態。
我想你想'explode('_',$ key,2);'作爲最後一個參數指定返回數組中元素的數量。你可以使用'list($ field,$ id)= explode('_',$ key,1);'以避免'$ tmp',fyi。最好確保下劃線先存在! – notJim 2010-05-24 08:20:07
是的,你是對的。 thx指出這一點。 – 2010-05-24 08:22:55
我想根據用戶爲特定儀器所做的條目更新表格。該代碼會給我所有的ID,但我想要他已經進入的ID。 – 2010-05-24 08:48:33