页面加载“未找到结果”时不可见

$search_code = $_POST['search_code'];
global $wpdb;
$helloworld_id = $wpdb->get_var("SELECT s_image FROM search_code WHERE s_code = $search_code");
 if (empty($helloworld_id)) { 
 echo '<div class="no_results">No results found</div>'; 
 }else 
 { ?>
  <img src="http://igtlaboratories.com/wp-content/uploads/images/<?php echo $helloworld_id; ?>"style="width:200px;height: auto;">
<?php
  }
}

I using this code but when page load by default "no result found" visible . how i disable on page load. Any help.

Thanks in advance

It simple, add Condition above the your search code and put your all code inside this condition. Please check below code

Used isset () in condition for Determine if a variable is set and is not NULL and !empty()

if(isset($_POST['search_code']) && !empty($_POST['search_code']))
{
    // Your code goes here 
    $search_code = $_POST['search_code'];
    global $wpdb;
    $helloworld_id = $wpdb->get_var("SELECT s_image FROM search_code WHERE s_code = $search_code");
    if (empty($helloworld_id)) { 
        echo '<div class="no_results">No results found</div>'; 
    }else { ?>
        <img src="http://igtlaboratories.com/wp-content/uploads/images/<?php echo $helloworld_id; ?>"style="width:200px;height: auto;">
    <?php }
}

just try this

if(isset($_POST['search_code']) && !empty($_POST['search_code']))
{
    $search_code = $_POST['search_code'];
    global $wpdb;
    $helloworld_id = $wpdb->get_var("SELECT s_image FROM search_code WHERE s_code = $search_code");
    if (empty($helloworld_id)) { 
        echo '<div class="no_results">No results found</div>'; 
    }else{ ?>
        <img src="http://igtlaboratories.com/wp-content/uploads/images/<?php echo $helloworld_id; ?>"style="width:200px;height: auto;">
    <?php }
}

This is undefined index

   $search_code = $_POST['search_code'];

So I would change that to

   $search_code = isset( $_POST['search_code'] ) ? $_POST['search_code']  : false;

Then wrap the other part in an if statement

 if( $search_code ){
    global $wpdb;

    $helloworld_id = $wpdb->get_var("SELECT s_image FROM search_code WHERE s_code = $search_code");

    if (empty($helloworld_id)) { 
         echo '<div class="no_results">No results found</div>'; 
    }else{
        echo '<img src="http://igtlaboratories.com/wp-content/uploads/images/'.$helloworld_id.'"style="width:200px;height: auto;">';
    }
  }//end if $search_code

Also mixing the echo with the PHP start and end blocks in the if else statement looked weird to me so I fixed that too.