I have the following html-php input field on a form page:
<input type="text" id="subnet" name="subnet" class="inputText70px" maxlength="3" value=
<?php
if (!empty($eqptCheck['subnet'])){
echo '"'.$ipAddressArr['subnet'].'">.';
}else{
echo '"">.';
}
?>
Whenever I have any value other than 0 for the subnet it is displays properly in the page's input field. But when the subnet value is 0 the page's field is just empty. I assume my php must be the problem. Can anyone see what the issue with my php is that causes the issue?
I think empty
is true if for value == 0
. So when your subnet value is 0, then the !empty
condition is false and moves along to else
that renders an empty ""
value for the intput field.
If you instead use !is_null
in place of !empty
I think that should resolve your issue.
<input type="text" id="subnet" name="subnet" class="inputText70px" maxlength="3" value=
<?php
if (!is_null($eqptCheck['subnet'])){
echo '"'.$ipAddressArr['subnet'].'">.';
}else{
echo '"">.';
}
?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With