Part 5 Creation of the INSERT into database

First find out how many rows has been submitted and removed – $repeatTimes

        //find out the max number of database rows
        $dbRow;
        //find out the max number of submitted rows
        $subRow = count($eduID);

        $repeatTimes;

        if ($dbRow > $subRow){
            $repeatTimes = $dbRow;
        } else {
            $repeatTimes = $subRow;
        }

Secondly, insert into database the submitted rows without a existing eduID

if (!empty($Qualification)){

                $i=0;

                for ($int = 0; $int<$repeatTimes; $int++){

                            $Startyear_esc[$i] = $db->mysql_escape($Startyear[$i]);
                            $Endyear_esc[$i] = $db->mysql_escape($Endyear[$i]);
                            $School_esc[$i] = $db->mysql_escape($School[$i]);
                            $Course_esc[$i] = $db->mysql_escape($Course[$i]);
                            $Qualification[$i] = $db->mysql_escape($Qualification[$i]);
                            $educationID[$i] = $db->mysql_escape($eduID[$i]);

                            if(empty($Educationinput_esc) && !empty($Qualificationinput_esc)){

                                //insert
                                $query = "INSERT INTO education (Startyear, Endyear, School, Course, Qualification, member_Member_id) VALUE ('$Startyearinput_esc', '$Endyearinput_esc', '$Schoolinput_esc', '$Courseinput_esc', '$Qualificationinput_esc', '$memberId')";      
                                $queryResult = $db->writeQuery($query);

                                if (!empty($queryResult)){
                                    //echo "Successfully inserted new entries.";
                                    $database_mod = TRUE;
                                    $i++;
                                }
                    }
}