In my attempt to simulate array_intersect in PHP3, I tried nesting 
while statements.  While traversing one array to display checkboxes, 
I wanted to loop through another array, testing to see if any of the 
values in it match the current value in the outer while loop.

What I'm getting is that the inner while loop executes on the first 
execution of the outer while, and then not at all.  How would I get 
it to execute each time?

Here's the code:

$childquery = "select * from flavors order by flavor";
$childtype = "flavor";
$childresult = mysql_query($childquery) or die(mysql_error());

$relationsquery = "select * from relations where 
childtype='$childtype' and parenttype='$parenttype' and 
parentsku='$parentsku'";
$relationsresult = mysql_query($relationsquery) or die(mysql_error());

?>

<form action="<?php echo $PHP_SELF?>" method="post">
...various form variables...
<h3>Parent: <?php echo $parent ?></h3>

<?php

while ($row = mysql_fetch_array($childresult)) {

        $thevalue = $row["flavorsku"];
        $thedisplay = $row["flavor"];

        printf("<input type=\"checkbox\" name=\"childsku[]\" 
value=\"%s\"", $thevalue);

        while ($relationsrow = mysql_fetch_array($relationsresult)) {

                $thischild = $relationsrow["childsku"];
                        if ($thevalue == $thischild) {
                                echo " checked";
                        }
        } // end while relations loop


        printf(">%s<br>\n", $thedisplay);

} //end the child results while loop



Thanks for any suggestions!
-- 
Maurice Rickard
http://mauricerickard.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to