Unexpected 'endforeach' in code
<p>Below are lines of my code. I have a foreach loop to print values into a table. It results in an error saying </p>

<blockquote>
  <p>"Parse error: syntax error, unexpected 'endforeach' (T_ENDFOREACH)"</p>
</blockquote>

<p>I can't seem to figure out where I have gone wrong.</p>

<pre><code>&lt;?php foreach (getStaffDetails() as $staffDetails): 
if($staffDetails['admin_confirm'] == 1) 
  {?&gt;
  &lt;tr&gt;                             
  &lt;td&gt;&lt;?php echo $staffDetails['name']; ?&gt;&lt;/td&gt;                               
  &lt;td&gt; &lt;?php echo $staffDetails['staff_id']; ?&gt;&lt;/td&gt;
  &lt;td&gt; &lt;?php $dept= $staffDetails['dept_id']; 
            $dept_name= getDeptName($dept);
            echo $dept_name;?&gt; &lt;/td&gt; 
  &lt;td&gt; &lt;?php echo $staffDetails['email_id']; ?&gt;&lt;/td&gt;
  &lt;td&gt; &lt;?php echo $staffDetails['ph_no']; ?&gt;&lt;/td&gt;
  &lt;td&gt; &lt;?php echo $staffDetails['gender']; ?&gt;&lt;/td&gt;
  &lt;td&gt; &lt;?php echo $staffDetails['doj']; ?&gt;&lt;/td&gt; 
&lt;?php endforeach; ?&gt;
</code></pre>