I need to read an array's content using a while loop and inside the loop
read another array's content. Using the variables from the two arrays I need
to execute a query. My problem is the inner while loop reads all records of
the array whereas the outer while loop exits after reading the first record.
That is after execution of the inner while loop finishes, the control does
not move to the outer while loop to read the next array element.

I am appending my code below. Please help me solve this problem

$arrdata  = mysql_query("SELECT OldDeptCode, MajorCode FROM
tblolddeptcodemajorcode");

$result2 = mysql_query("SELECT SSN, DeptCode, ActCode FROM
tblapprovedactivitydetail");

while($info = mysql_fetch_assoc($arrdata))
{
     $OldDeptCode = $info['OldDeptCode'];
     $MajorCode = $info['MajorCode'];

    while($row2 = mysql_fetch_assoc($result2))
    {
        $SSN = $row2['SSN'];
        $DeptCode = $row2['DeptCode'];
        $ActCode = $row2['ActCode'];

        $query = "INSERT INTO test1 (SSN, MajorCode, ActCode) VALUES
('$SSN', '$MajorCode', '$ActCode')";

        if($OldDeptCode != 'COAS' && $OldDeptCode != 'CSS' && $OldDeptCode
!= 'EC' && $OldDeptCode != 'EECS' && $OldDeptCode != 'FW' && $OldDeptCode !=
'GEO' && $OldDeptCode != 'SED' && $OldDeptCode != 'VM' && $OldDeptCode ==
$DeptCode)
        {
        mysql_query($query);
        }
   }
    echo "done";
}
echo "all done";



Thank you

Reply via email to