hi can anyone help me with this? i really had a hard time putting my if statement in this code
<select name="date_opened_year">
<?php
define('DOB_YEAR_START', 1962);
$current_year = date('Y');
for ($count = $current_year; $count >= DOB_YEAR_START; $count--)
{
echo "<option value='{$count}'>{$count}</option>";
}
?>
</select>
and i have here a code where i had put my if statement
<select name="date_opened_year">
<?php
define('DOB_YEAR_START', 1962);
$current_year = date('Y');
for ($count = $current_year; $count >= DOB_YEAR_START; $count--)
{
echo "<option value='{$count}' if($yy == $count) echo 'selected'>{$count}</option>";
}
?>
</select>
$yy = 2003 well it comes from a query in the database and when i look at the code it gives me something like this
<option 'selected'="" echo="" 2012)="" if(2003="=" value="2012">2012</option>
why is that? can anyone revise the code? thanks
try this:
Best to break it up.
You’ve got your if inside a string creation double quote.