confusion about WHILE within a WHILE
Posted: Sat Nov 11, 2006 11:31 pm
I'm going crazy! Can someone please point out how to make this code work properly... I am simply trying to display a list of all items from 1 table with checkboxes next to each item,and then pre-check some of those boxes based on values from a lookup table.
Currently, this is only pre-checking one box correctly (the last value in the table) even when there should be multiple boxes checked so there must be something wrong with my first WHILE or maybe just where it is???
Thank You.
Jcart | Please show of the curtosy of properly indenting your code next time, thanks
Code: Select all
<?php //Display all cases via checkboxes and pre-check the current values
while ($selectedcase = mysql_fetch_array($selectedcases)) {
$caseid = $selectedcase['caseid'];
while ($case = mysql_fetch_array($cases)) {
$case_prodid = $case['prodid'];
$prodname = htmlspecialchars($case['prodname']);
if ($case_prodid == $caseid) { ?>
<input name="case_prodids[]" type="checkbox" value="<?php echo $case_prodid; ?>" checked> <?php echo $prodname; ?><br /><?php
}else{ ?>
<input name="case_prodids[]" type="checkbox" value="<?php echo $case_prodid; ?>"> <?php echo $prodname; ?><br /><?php
}
}
}Thank You.
Jcart | Please show of the curtosy of properly indenting your code next time, thanks