I’m building a dropdown menu populated from a php range of numbers. My code works so far. Here’s how I’ve written it so far:
<?php
echo "<select name='Strength_Pts2' id='Strength_Pts2'>";
foreach($PotRange as $AttributesAvailable)
{
echo "<option value='$AttributesAvialabe'>$AttributesAvailable</option>";
}
echo "</select>";
?>
Now, I’d like to add an If/Then condition to the menu, so under certain circumstances the user will only get an option of ‘0’ instead of the whole range. Here’s what I coded:
<?php
echo "<select name='Strength_Pts2' id='Strength_Pts2'>";
if ( 1 == 1 ) {
foreach($PotRange as $AttributesAvailable)
{
echo "<option value='$AttributesAvialabe'>$AttributesAvailable</option>";
}
else
echo "<option value='0'>0</option>";
}
echo "</select>";
?>
I’ve tried it with and without a ; after the last }. I get Parse error: syntax error, unexpected T_ELSE on line 531.
Can anybody help out with what I’m doing wrong?
Thanks in advance, -CB
You forgot some curly braces, use the following: