I 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.
Here is demo of my code: http://codepad.viper-7.com/siDC84Row 0-1: a,aaa,AA
Row 0-2: b,BB
Row 0-3: c,CC
Row 1-1: aa,AA
Row 1-2: b,bbb,BB
Row 1-3: cc,ccc,CC
Row 2-1: aa,aaa,AA
Row 2-2: b,bbb,BB
Row 2-3: c,cc,CC
How to change the html and php code to get the desired result?
My html code is as:
My php code is as:Code:<form action="#" method="post"> <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="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="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="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="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="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="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="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="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>
PHP 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('hoV', $DateArray); This is for CodeIgniter
}
?>


Reply With Quote
Bookmarks