[eluser]SaSa[/eluser]
I use CodeIgniter and want values in html code that is checked and values input text inserted batch in database mysql , As follows:
in
0-1 or ... ,
0 is same
checkboxDA[0][].
Row is same rows database table.
Quote:Row 0-1: a,aaa,AA<br>
Row 0-2: b,BB<br>
Row 0-3: c,CC<br>
Row 1-1: aa,AA<br>
Row 1-2: b,bbb,BB<br>
Row 1-3: cc,ccc,CC<br>
Row 2-1: aa,aaa,AA<br>
Row 2-2: b,bbb,BB<br>
Row 2-3: c,cc,CC<br>
Here is demo of my code: http://codepad.viper-7.com/siDC84
How should I change to get the desired result?
My html code is as:
Code:
<form acti method="post">
<input type="text" name="IdRelInto[]" value="111" none">
<input type="text" name="IdRelTo[]" value="1111" none">
<input type="checkbox" name="checkboxDA[0][]" value="a" checked>a
<input type="checkbox" name="checkboxDA[0][]" value="aa" >aa
<input type="checkbox" name="checkboxDA[0][]" value="aaa" checked>aaa
<input type="text" name="prts[]" value="AA">
<input type="text" name="IdRelTo[]" value="1111" none">
<input type="checkbox" name="checkboxDA[0][]" value="b" checked>b
<input type="checkbox" name="checkboxDA[0][]" value="bb" >bb
<input type="checkbox" name="checkboxDA[0][]" value="bbb" >bbb
<input type="text" name="prts[]" value="BB">
<input type="text" name="IdRelTo[]" value="1111" none">
<input type="checkbox" name="checkboxDA[0][]" value="c" checked>c
<input type="checkbox" name="checkboxDA[0][]" value="cc" >cc
<input type="checkbox" name="checkboxDA[0][]" value="ccc" >ccc
<input type="text" name="prts[]" value="CC">
<input type="text" name="IdRelInto[]" value="222" none" none">
<input type="text" name="IdRelTo[]" value="2222" none">
<input type="checkbox" name="checkboxDA[1][]" value="a" >a
<input type="checkbox" name="checkboxDA[1][]" value="aa" checked>aa
<input type="checkbox" name="checkboxDA[1][]" value="aaa" >aaa
<input type="text" name="prts[]" value="AA">
<input type="text" name="IdRelTo[]" value="2222" none">
<input type="checkbox" name="checkboxDA[1][]" value="b" checked>b
<input type="checkbox" name="checkboxDA[1][]" value="bb" >bb
<input type="checkbox" name="checkboxDA[1][]" value="bbb" checked>bbb
<input type="text" name="prts[]" value="BB">
<input type="text" name="IdRelTo[]" value="2222" none">
<input type="checkbox" name="checkboxDA[1][]" value="c" >c
<input type="checkbox" name="checkboxDA[1][]" value="cc" checked>cc
<input type="checkbox" name="checkboxDA[1][]" value="ccc" checked>ccc
<input type="text" name="prts[]" value="CC">
<input type="text" name="IdRelInto[]" value="333" none">
<input type="text" name="IdRelTo[]" value="3333" none">
<input type="checkbox" name="checkboxDA[2][]" value="a" >a
<input type="checkbox" name="checkboxDA[2][]" value="aa" checked>aa
<input type="checkbox" name="checkboxDA[2][]" value="aaa" checked>aaa
<input type="text" name="prts[]" value="AA">
<input type="text" name="IdRelTo[]" value="3333" none">
<input type="checkbox" name="checkboxDA[2][]" value="b" checked>b
<input type="checkbox" name="checkboxDA[2][]" value="bb" >bb
<input type="checkbox" name="checkboxDA[2][]" value="bbb" checked>bbb
<input type="text" name="prts[]" value="BB">
<input type="text" name="IdRelTo[]" value="3333" none">
<input type="checkbox" name="checkboxDA[2][]" value="c" checked>c
<input type="checkbox" name="checkboxDA[2][]" value="cc" checked>cc
<input type="checkbox" name="checkboxDA[2][]" value="ccc" >ccc
<input type="text" name="prts[]" value="CC">
<input type="submit" value="Submit">
</form>
My php code is as:
Code:
<?php
if($_POST){
foreach ($_POST['IdRelInto'] as $idx1 => $value1) {
foreach ($_POST['IdRelTo'] as $idx => $value) {
$DateArray[] = array(
'checkboxDA' => $_POST['checkboxDA'][$idx],
'prts' => $_POST['prts'][$idx],
'IdRelInto' => $_POST['IdRelInto'][$idx],
'IdRelTo' => $_POST['IdRelTo'][$idx]
);
};
};
echo '<pre>';
print_r($DateArray);
//$this->db->insert_batch('hotel_unitsPV', $dataPV); This is for CodeIgniter
}
?>