php - Invisible when page load "No result found" -


$search_code = $_post['search_code']; global $wpdb; $helloworld_id = $wpdb->get_var("select s_image search_code 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 code when page load default "no result found" visible . how disable on page load. help.

thanks in advance

it simple, add condition above search code , put code inside condition. please check below code

used isset () in condition determine if variable set , not null , !empty()

if(isset($_post['search_code']) && !empty($_post['search_code'])) {     // code goes here      $search_code = $_post['search_code'];     global $wpdb;     $helloworld_id = $wpdb->get_var("select s_image search_code 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 } } 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -