The below HTML is the view source, that [1] is unique to the iid in the db, so in the next table it would be 2 and the next, 3, etc. I just showed this to help get an understanding of the value...
<td><input name="feature[1]" type="checkbox" checked/></td>
<td><input name="fashion[1]" type="checkbox" /></td>
This was designed to make the main array "feature", "fashion" etc, and then it would have been easier to pick the unique iid (number) out of the array.
$array = array('feature', 'fashion', 'beauty', 'hair', 'random');
if (isset($array)) {
foreach ($array as $category) {
if (isset($_POST[$category])) {
foreach ($_POST[$category] as $iid => $value) {
if ($value == "on") { $value = 1; }
echo "CATEGORY: " . $category . ", IID: " . $iid . ", VALUE: " . $value . "<br />";
}
}
}
}
If I have 3 rows in my db (users, iid), all users have feature checked, and 1 has fashion checked, that echo will generate the following:
CATEGORY: feature, IID: 3, VALUE: 1 <-- feature[3] checked
CATEGORY: feature, IID: 2, VALUE: 1 <-- feature[2] checked
CATEGORY: feature, IID: 1, VALUE: 1 <-- feature[1] checked
CATEGORY: fashion, IID: 1, VALUE: 1 <-- fashion[1] checked
My problem with this code is I have got myself into a pickle, where now I need to change/add to this code, a way to make it output iid with what has been ticked...
Ultimately it will be going into a database, so I was hoping to shape it so it would be...
UPDATE database SET feature=$a, fashion=$b, ... WHERE IID = $1
UPDATE database SET feature=$a, fashion=$b, ... WHERE IID = $2
UPDATE database SET feature=$a, fashion=$b, ... WHERE IID = $3
I didn't know if I could do such things as manipulate the 3 variables into a $iid[$category] to fake an array or something (hence why I'm in the newbie section) but I remember someone once telling me that arrays starting with numbers were a bad idea, and that is why I initially went down this path...
I really appreciate this. I have looked into so many different ways to do this, and I just cant make anything from it.. Any assistance is as I said, greatly appreciated.
Regards,
Skaype.