Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

167
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda