페이지에 게시하기 위해 일부 입력 필드가있는 작은 테이블을 사용하고 있습니다. 특정 악기 번호에 대해 사용자가 채우는 데이터를 검색하고 싶습니다.동적 게시물 값 검색
내 코드
<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);를 원한다고 생각합니다. '$ tmp', fyi를 피하기 위해서'list ($ field, $ id) = explode ('_', $ key, 1);'를 사용할 수 있습니다. 밑줄이 먼저 존재하는지 확인하는 것이 더 좋습니다! – notJim
네, 맞습니다. 이것을 가리키는 thx. –
특정 악기에 대해 사용자가 입력 한 내용을 기반으로 테이블을 업데이트하려고합니다. 이 코드는 나에게 모든 ID를 줄 것이다.하지만 나는 그가 id를 입력하고 싶다. –