I have an enum mysql field with a null value ''. I need that null value to be disabled in the dropdown list however it is showing the html <option> as <option/> Here is the code I have.
-
foreach($enums as $key)
-
{
-
echo "<option ".$func->iif($key==$results['Group'],'selected','').">".$func->makeSafe($key)."</option>";
-
}
I have also tried the following with no success either.
-
foreach($enums as $key)
-
{
-
if (is_null($key) || !isset($key))
-
echo "<option></option>";
-
else
-
echo "<option ".$func->iif($key===$results['Group'],'selected').">".$func->makeSafe($key)."</option>";
-
}
anyone know why this displays the null option as <option/> and not <option></option>?
How are you viewing the HTML source?
Some browsers will interpret a <tag></tag> as <tag />.
[HTML]if (is_null($key) || !isset($key))[/HTML]
Is useless here. isset($key) will always return true. NULL converts to an empty string with echo() so there is no need to test if its null, then write out the literal <option></option>.