php if in an option tag
<p>hi can anyone help me with this? i really had a hard time putting my if statement in this code</p>

<pre><code>&lt;select name="date_opened_year"&gt;
&lt;?php 
define('DOB_YEAR_START', 1962);
$current_year = date('Y');

for ($count = $current_year; $count &gt;= DOB_YEAR_START; $count--)
{
    echo "&lt;option value='{$count}'&gt;{$count}&lt;/option&gt;";
}
?&gt;
&lt;/select&gt;
</code></pre>

<p>and i have here a code where i had put my if statement </p>

<pre><code>&lt;select name="date_opened_year"&gt;
&lt;?php 
define('DOB_YEAR_START', 1962);
$current_year = date('Y');

for ($count = $current_year; $count &gt;= DOB_YEAR_START; $count--)
{
    echo "&lt;option value='{$count}' if($yy == $count) echo 'selected'&gt;{$count}&lt;/option&gt;";
}
?&gt;
&lt;/select&gt;
</code></pre>

<p>$yy = 2003 well it comes from a query in the database and when i look at the code it gives me something like this</p>

<pre><code>&lt;option 'selected'="" echo="" 2012)="" if(2003="=" value="2012"&gt;2012&lt;/option&gt;
</code></pre>

<p>why is that? can anyone revise the code? thanks</p>
