Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

165
Vistas
form field is blank when input value retreived from 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 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?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

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 '"">.';
    }
  ?>
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda