私の見解では、次の形式があります。
<table align="center" border="1">
<tr>
<td>Identificação</td>
<td>Conc, %</td>
<td>Classificação 67/548/CEE</td>
<td>Classificação 1272/2008 (CLP)</td>
</tr>
<tr>
<td>
<textarea rows="4" cols="30" name="componentes[0][identificacao]"></textarea>
</td>
<td>
<textarea rows="4" cols="30" name="componentes[0][conc]"></textarea>
</td>
<td>
<textarea rows="4" cols="30" name="componentes[0][classificacao_cee]"></textarea>
</td>
<td>
<textarea rows="4" cols="30" name="componentes[0][classificacao_clp]"></textarea>
</td>
</tr>
</table>
<div id="outro_curso"></div>
<p class="submit">
<button id="novo_curso">Add Curso</button>
</p>
ご覧のとおり、多次元配列を使用しています。「カーソルを追加」ボタンをクリックすると、前のテーブルと同様の別のテーブルを生成する jquery 関数が呼び出されるためです。テキスト領域の名前は、、、componentes[1][identificacao]
などになりcomponentes[1][conc]
ます...
注: ボタンを使用して、必要な回数だけテーブルを生成できます。
さて、私の問題は、このデータを CodeIgniter モデルで処理する方法です。データを配列に保存しようとしました$componentes
(後でデータベースに挿入するため)が、コードに何か問題があると思います:
$componentes;
foreach ($this->input->post('componentes') as $key => $value){
$componentes[$key]['identificacao']=$value[$key]['identificacao'];
$componentes[$key]['conc']=$value[$key]['conc'];
$componentes[$key]['classificacao_cee']=$value[$key]['classificacao_cee'];
$componentes[$key]['classificacao_clp']=$value[$key]['classificacao_clp'];
}
誰かが私に少し助けてもらえますか?
編集:
言及するのを忘れていましたが、エラーが発生しています:
foreach() に無効な引数が指定されました。
foreach ($this->input->post('componentes') as $key => $value){
したがって、私の説明が正しいのか、それとも内部の行に問題があるのか わかりません。