<?php//var_dump($_POST);//print "<br>"; //error_reporting(E_ALL & ~E_NOTICE);include("navigation.php");include("config.php");// I'm assuming that dropdown 1_1 is the first one, 1_2 is the second one and so on.// subcat_1_1_1 is the first checkbox in the first dropdown in the first of the three sections.// subcat_1_1_2 is the second checkbox in that dropdown and so on.$name = $_POST['name'];$green = $_POST['green'];$eco = $_POST['eco'];$dfe = $_POST['dfe'];$cate = array();foreach($_POST AS $key => $value) { if (is_int(strpos($key,"cattag"))) { $t = explode("_",$key); $a = $t[1]; $b = $t[2]; $c = $t[3]; $cate[$a][$b][$c] = $value; }}echo "<br>";echo sizeof($cate);echo "<br>cate:<br>";var_dump($cate);echo "<br>";$categories = array();foreach($_POST AS $key => $value) { if (is_int(strpos($key,"subcat"))) { $t = explode("_",$key); $a = $t[1]; $b = $t[2]; $c = $t[3]; $categories[$a][$b][$c] = $value; }}print "<br>categories dump<br>";var_dump($categories);echo sizeof($categories);print "end categories dump<br>";print "<br>";// Now you have an array with all checkboxes, something like// $subcat[1][1][1] = The number of the first checked checkbox in the first category// $subcat[1][1][2] = The number of the second checked checkbox in the first category and so on.// $subcat[1][2][1] = The number of the first checked checkbox in the second category// $subcat[1][2][2] = The number of the second checked checkbox in the second category and so on.// $subcat[2][1][1] = The number of the first checked checkbox in the first category, second section// $subcat[2][1][2] = The number of the second checked checkbox in the first category, second section and so on.$key_exists = true;$subkey_exists = true;$strings = array();// Loops through and turns all categories' arrays into stringsforeach ($categories AS $key1 => $array1) { foreach ($array1 AS $key2 => $array2) { $strings[$key1][$key2] = implode(';', $array2); }} echo sizeof($strings);print "<br>strings start<br>";var_dump($strings);print "<br>strings end<br><br>"; // Now strings[] contains all the strings (like 1;3;5 and 3;5;7). Loop through the array:foreach ($strings AS $key1 => $array1) { foreach ($value1 AS $key2 => $array2) { printf( "INSERT into item_new (name, green, eco, dfe, section, category, subcategory) VALUES ('%s','%s','%s','%s','%s','%s',';%s;')<br> ", $name, $green, $eco, $dfe, $key1, $cate[$key1][1][$key2], $array2); }} // Done.// Store that field in the DB and then when you want them into an array again, do:// $array = exlode(';', $string);echo "<font color=green>Successfully Inserted info Database</font>";?>