【发布时间】:2010-12-16 17:36:11
【问题描述】:
我正在 CodeIgniter 中构建一个应用程序。我有一个使用 jQuery 创建新行项目的发票表单。行项目的格式如下:
<input type="text" name="invoice[new_item_attributes][][description]" class="ui-corner-all text invDesc" title="Description" />
<input type="text" name="invoice[new_item_attributes][][qty]" class="ui-corner-all text invQty" title="Qty" />
<input type="text" name="invoice[new_item_attributes][][amount]" class="ui-corner-all text invAmount" title="Amount" onChange="CalculateTotal(this.form)" />
<input type="hidden" name="invoice[new_item_attributes][][rowTotal]" class="row-total-input" />
我无法解决的是如何循环遍历多个行项目,然后将其存储在称为行项目的数据库中。
我现在有
foreach ( $_POST['invoice'] as $key => $value)
{
$data = array(
'description' => $value;
);
}
但我知道这不能写,因为我需要以某种方式引用 invoice[new_item_attributes][][description] 以将其存储在描述等中......
任何帮助将不胜感激。
【问题讨论】:
标签: php mysql arrays forms codeigniter