The form field is empty when the input value received from the database is 0

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 a value other than 0 for the subnet, it displays correctly in the page input box. But when the subnet value is 0, the page field is simply empty. I assume my php should be a problem. Can anyone see that the problem with my php is causing the problem?

+6
source share
1 answer

, empty , value == 0. , 0, !empty false else, "" intput.

!empty !is_null, , .

<input type="text" id="subnet" name="subnet" class="inputText70px" maxlength="3" value=
  <?php
    if (!is_null($eqptCheck['subnet'])){
      echo '"'.$ipAddressArr['subnet'].'">.';
    }else{
      echo '"">.';
    }
  ?>
+6

Source: https://habr.com/ru/post/1016587/


All Articles