let me be more specific, maybe somebody will bite. 🙂
<FORM ACTION= ' . ($PHP_SELF) . ' METHOD=POST>
';
if ($sizeId) {
//print data to confirm
$i=0;
$t=0;
while(list($i,$t) = each($allsizes)) {
foreach($_POST['sizeId'] as $key=>$value) {
if (($sizeId[$key]) == ($allsizes[$value])) {
//this should be data checked from submission
$status.='inner loop ch<input type=\'checkbox\' name=\'sizeId[]\' value=\''.$i.'\' checked>'.$allsizes[$value].' <br>';
} else {
//this should be unchecked data
$status.='inner loop un<input type=\'checkbox\' name=\'sizeId[]\' value=\''.$i.'\' >'.$allsizes[$value].' <br>';
}
}
//this should be all other elements unchecked
$status.='outer loop<input type=\'checkbox\' name=\'sizeId[]\' value=\''.$i.'\'>'.$allsizes[$value].' <br>';
$i++;
}
} else { //if ($sizeId)
// no sizeId defined, first time through or no data passed
$sizeN = array();
$allsizes = array();
$sizes = mysql_query("SELECT sizeId, size FROM sizes ORDER by sizeId") or die("size query crashed ". mysql_error());
while ($sizeN = mysql_fetch_array($sizes)) {
$sizeId[$sizeN[0]] = $sizeN[1];
$allsizes[$sizeN[0]] = $sizeN[1];
}
while(list($key,$value) = each($sizeId)) {
$status .='nosizeid<input type=\'checkbox\' name=\'sizeId[]\' value=\''.$key.'\'>'.$value.' <br>';
}
} // else
foreach ($allsizes as $key =>$value) {
$status .='<input type=\'hidden\' name=\'allsizes['.$key.']\' value = \''.$value.'\'>';
}
$status .='<p><input type=\'submit\' name=\'submitProduct\' value=\'Add Product\'></form>';
echo $status;
the problem is in the
while(list($i,$t) = each($allsizes)) {
foreach($_POST['sizeId'] as $key=>$value) {
if (($sizeId[$key]) == ($allsizes[$value])) {
section.
It doesn't loop through the two variables, allsizes & sizeId correctly. I alternate checked and unchecked for only the sizeId[] submitted checked. How can I change that iteration?