Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

166
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!