Hello,
I’m a bit of a newbie and stuck on the approach/syntax of how to do something pretty simple. I have a PHP for loop creating a bunch of options for a form drop-down. I cannot figure out how to either pull in the i iteration or get the right syntax to make this work inside an EE {if} statement.
I know it’s simple! Anyone point me in the right direction? Better way to approach this?
<select name="bday_y">
<option value="" disabled>Year</option>
<?php $date = date("Y");
for($i=$date-18;$i>$date-100;$i--){
echo '<option value="'.$i.'" {if bday_y == $i }selected="selected"{/if}> '.$i.' </option> ';
}
?>
</select>I know the main issue is with:
{if bday_y == $i }I’ve tested everything else and it’s all working fine otherwise—just not pulling the $i inside the EE code!