PHP: Inserting data to another table
<p>I have the function below that tells the database weather to update or insert dependent on if the email address has been found this works fine however I still have some <code>$POST</code> information that needs to go into another table dependent on the <code>id</code></p>

<p>I have got it worked out that for the <code>if($emailCheck != FALSE)</code> statement I can run another <code>insert</code> statement and set the <code>id</code> within that</p>

<p>My question is how could I achieve this for the new <code>insert</code> of information in the <code>else</code> statement?</p>

<p><strong>Insert Function:</strong>  </p>

<pre><code>function Insert()
{
  $emailCheck = $this-&gt;checkEmail($email);

  if($emailCheck != FALSE)
  {
    updateQuery by $emailCheck['id'])); // The email address is found so we update the data

  }else{

    Jojo::insertQuery; // The email address is not found so we insert the new row
  }
}
</code></pre>

<p><strong>Check Function:</strong></p>

<pre><code>function checkEmail($email)
{
     $email = $POST['Email'];

    if($email)
    {
        $candemail = selectRow("SELECT * FROM {table} WHERE email=?",$email);

        if(isset($candemail['email']))
        {
            return $candemail;
        } else {
            return FALSE;
        }
    }
}
</code></pre>

<p><strong>Full function:</strong></p>

<pre><code>  function candidateInsert($fields, $candiatefilename,$jobid)
    {
      $emailCheck = Jojo_Plugin_name_jobs_apply::checkCandidateEmail($email);

      if($emailCheck != FALSE)
      {
        //Jojo::updateQuery("UPDATE {db} SET first_name=?,last_name=?,home_phone=?,work_phone=?,mobile_phone=?,email=?,skype=?,contact_method=?,location=?,location_other=?,cv_path=? WHERE id=?", array($fields['FirstName'],$fields['LastName'],$fields['HomePhone'],$fields['WorkPhone'],$fields['MobilePhone'],$fields['Email'],$fields['Skype'],$fields['ContactMethod'],$fields['Location'],$fields['LocationOther'],$candiatefilename, $emailCheck['id']));
        //Jojo::insertQuery("INSERT INTO {refocus_candidate_job} SET candidateID=?,jobID=?,appliedDate=?", array($emailCheck['id'],$jobid,date("d/m/y")));
    }else{
        Jojo::insertQuery("INSERT INTO {db} SET first_name=?,last_name=?,home_phone=?,work_phone=?,mobile_phone=?,email=?,skype=?,contact_method=?,location=?,location_other=?,cv_path=?", array($fields['FirstName'],$fields['LastName'],$fields['HomePhone'],$fields['WorkPhone'],$fields['MobilePhone'],$fields['Email'],$fields['Skype'],$fields['ContactMethod'],$fields['Location'],$fields['LocationOther'],$candiatefilename));

        $id = Jojo::insertQuery;

        //Jojo::insertQuery("INSERT INTO {db_candidate_job} SET candidateID=?,jobID=?,appliedDate=?", array($id,$jobid,date("d/m/y")));

        }
    }
</code></pre>
