jeudi 25 février 2016

PHP variable value not updating

this is my first question here, but I use this a lot, so sorry for anything.

foreach($quizzData->questions->children() as $quest)
    {
        $questDesc = $quest->direction;
        $offset = 1;

        if(strpos($questDesc, "student") !== false)
        {
            foreach($quest->answers->children() as $questChild)
            {
                $name = trim($questChild);
                $result = $db->executeSQL("CALL SPU_SE_STUDENT_ID('$name')")->fetch_assoc();
                $studentID = $result['ID_STUDENT'];
                $db->freeResult();
                $pos = $questChild['userDefinedPosition'] + $offset;

                if( $quizSummary['studentID'] == $studentID)
                {
                    $offset = 0;
                    $sql = "CALL SPU_IN_STUDENT_EVAL_SUMMARY ($period, {$quizSummary['studentID']}, $studentID,0)"; 
                    $db->executeSQL($sql);
                    $db->freeResult();
                }
                else
                {
                    $sql = "CALL SPU_IN_STUDENT_EVAL_SUMMARY ($period, {$quizSummary['studentID']}, $studentID,$pos)"; 
                    $db->executeSQL($sql);
                    $db->freeResult(); 
                }

            }
        }

    }

The Code runs without errors, but the variable $offset doesn't change inside the if, and the if code IS being executed because I validated it on the database. The $db variable is an instance of another class, and that class doesn't have any variables named $offset. I Have no idea why it's not working, can anyone help me ?

Thanks a lot in advance.

Aucun commentaire:

Enregistrer un commentaire