データベースからの製品データがあり、編集フォームで入力の値を設定しようとしていますが、for および foreach ループを管理する方法がわかりません :( ここに私が試しているコードがあります
<table id="dyTable">
<thead>
<th style="width:20px; padding-right:10px;">No.</th>
<th style="width:70px; padding-right:10px;">Quantity</th>
<th style="width:290px; padding-right:10px;">Product</th>
<th style="width:100px; padding-right:10px;">Unit Price</th>
</thead>
<tbody>
<?php
for($r=1; $r<=$pr_value; $r++){
foreach($inv_products as $prod):
$quantity.$r = array('name' => $quantity.$r,
'id' => $quantity.$r,
'type' => 'text',
'value' => $this->form_validation->set_value($prod->quantity),
'class' => 'text',
'style' => 'width: 70px; text-align: center;'
);
$product.$r = array('name' => $product.$r,
'id' => $product.$r,
'type' => 'select',
'value' => $this->form_validation->set_select($prod->product_id),
'class' => 'chzn-select',
'style' => 'width:300px;'
);
$unit_price.$r = array('name' => $unit_price.$r,
'id' => $unit_price.$r,
'type' => 'text',
'value' => $this->form_validation->set_value($prod->unit_price),
'class' => 'text',
'style' => 'width: 100px; text-align: right;'
);
?>
<tr id="line<?php echo $r; ?>">
<td style="width: 20px; text-align: center; padding-right: 10px; padding-right: 10px;"><?php echo $r; ?></td>
<td><?php echo form_input($quantity.$r);?></td>
<td><?php echo form_dropdown($product.$r); ?></td>
<td><?php echo form_input($unit_price.$r);?></td>
</tr>
<?php
endforeach;
}
?>
</tbody>
$r は配列になります。これを達成する方法を教えてください。事前に感謝します