PHP: Why do I get syntax error, unexpected 'endwhile' (T_ENDWHILE)?
<p>PHP: Why do I get syntax error, unexpected 'endwhile' (T_ENDWHILE) on line 38? I'm trying to create a forum for the first time with php and mysql and I'm not sure what's wrong with my code.</p>

<pre><code>&lt;?php
session_start();
require"db_connect.php";

$sql = "SELECT forum_id, forum_name FROM forum_tbl";
if ($query = $db-&gt;prepare($sql)){
    $query-&gt;bind_result($f_id, $f_name);
    $query-&gt;execute();
    $query-&gt;store_result();
}else{
    echo $db-&gt;error;
}

?&gt;

&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"&gt;

&lt;head&gt;
&lt;title&gt;Forum&lt;/title&gt;
&lt;meta/&gt;
&lt;style type="text/css"&gt;
&lt;/style&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;div class="container"&gt;
&lt;div class="content"&gt;
    &lt;table align="center" width="80%"&gt;
        &lt;?php
        if($query-&gt;num_rows !==0)
        while($row = $query-&gt;fetch())
        ?&gt;  
        &lt;tr&gt;
        &lt;td&gt;&lt;a href="forum.php?id=&lt;?php echo $f_id?&gt;"&gt;&lt;?php echo $f_name;?&gt;    &lt;/a&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;?php endwhile; endif;?&gt;    
    &lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
