I am putting checkbox values into an array. For certain selections, DB has value of 1, but query below is returning 0. What am I doing wrong? TY! also attached DB schema image.
db.pngPHP Code:$box=$_POST['box'];
if ($box != 0) {
while (list ($key,$val) = each ($box)) {
$val1 = "$val, ";
echo "$val1";
$a = $a + 1 ;
}
}
for ($j = 0; $j <= $a-1; $j++) {
for ($i = 0; $i <= $a-1; $i++) {
$box1 = $box["$i"] ;
$box2 = $box["$j"] ;
$queryziptrack2 = mysql_query("SELECT $box1 FROM paint WHERE color=$box2") or die ('Error: ' . mysql_error ());
$queryziptrack1 = mysql_fetch_array($queryziptrack2);
if (mysql_num_rows($queryziptrack2) == 0) {
echo "No rows found, nothing to print so am exiting";
exit;
}
if ($queryziptrack1["$box1"] == 1) {
$masking = "<font color=red>Extra masking is required.</font>" ;
echo "<font color=red>Extra masking is required.</font>" ;
exit;
} else {
$masking1 = "<font color=red>Extra masking is not required.</font>" ;
}
}
}
if (!$masking) {
echo $masking1 . "<br>" ;
} else {
echo $masking . "<br>" ;
}
echo "<br>Select colors and press 'tell me' button to see if extra masking is needed.<br><br> " ;
echo "<form method=post action=''>";
echo "<table border='0' cellspacing='0' style='border-collapse: collapse' width='200' >
<tr bgcolor='#ffffff'>
<td width='25%'><input type=checkbox name=box[] value='black' $t1v/></td>
<td width='25%'> Black</td>
<td width='25%'><input type=checkbox name=box[] value='white' $t2v/></td>
<td width='25%'> White</td>
<td width='25%'><input type=checkbox name=box[] value='red' /></td>
<td width='25%'> Red</td>
<td width='25%'><input type=checkbox name=box[] value='blue' /></td>
<td width='25%'> Blue</td>
<td width='25%'><input type=checkbox name=box[] value='yellow' /></td>
<td width='25%'> Yellow</td>
</tr>
<tr bgcolor='#f1f1f1'>
<td width='25%'><input type=checkbox name=box[] value='green' /></td>
<td width='25%'> Green</td>
<td width='25%'><input type=checkbox name=box[] value='orange' /></td>
<td width='25%'> Orange</td>
<td width='25%'><input type=checkbox name=box[] value='silver' /></td>
<td width='25%'> Silver</td>
<td width='25%'><input type=checkbox name=box[] value='ivory' /></td>
<td width='25%'> Ivory</td>
<td width='25%'><input type=checkbox name=box[] value='magenta' /></td>
<td width='25%'> Magenta</td>
</tr>
<tr bgcolor='#ffffff'>
<td width='25%'><input type=checkbox name=box[] value='burgundy' /></td>
<td width='25%'> Burgundy</td>
<td width='25%'><input type=checkbox name=box[] value='plum' /></td>
<td width='25%'> Plum</td>
<td width='25%'><input type=checkbox name=box[] value='brown' /></td>
<td width='25%'> Brown</td>
<td width='25%'><input type=checkbox name=box[] value='pink' /></td>
<td width='25%'> Pink</td>
<td width='25%'><input type=checkbox name=box[] value='purple' /></td>
<td width='25%'> Purple</td>
</tr>
<tr><td colspan =6> </td></tr>
<tr><td colspan =6><input type=submit value='Tell Me'></form></td></tr>
</table>";
?>



Reply With Quote


Bookmarks