title: Search result on click of button in popup
body: <p>I want to display search result on click of button, but my code is giving me the search result without click on button.</p>
  
  <p>I think it's giving me the query result not the search result.</p>
  
  <p>This code is working fine when I display the result on the page, but as per my requirement I want to display the search result on a popup.</p>
  
  <p>I have used jquery popup.</p>
  
  <pre><code>&lt;body&gt;&lt;form action="#" method="POST"&gt;&lt;body&gt;&lt;form action="#" method="POST"&gt;&lt;div data-role="page"&gt;
  
  &lt;div data-role="main" class="ui-content" &gt;
  
  &lt;a href="#a" data-rel="popup" class="ui-btn" onclick="result()" data-transition="slidefade"&gt;Smart Search&lt;/a&gt;
  
  &lt;/div&gt;
  
   &lt;div data-role="popup" id="a" class="col-sm-6 ui-content"&gt;
   &lt;div class="input-group col-sm-8"&gt;      
                                    &lt;input type="text" name="query" class="form-control" placeholder="Search Products to Buy..."  "  /&gt;
  
                                                    &lt;span class="input-group-btn"&gt;
                                                                              &lt;button name ="search_btn" id ="search class="btn btn-warning" type="submit" value="Search" style="background-color:orange;"&gt;Search&lt;/button&gt;
                                                    &lt;/span&gt;
  
      &lt;/div&gt;&lt;div class="input-group col-sm-8 " &gt;&lt;table class="table table-hover"&gt;
                     &lt;thead &gt;
                           &lt;tr bgcolor="#1E90FF"&gt;
                                  &lt;th&gt;Products&lt;/th&gt;
                                  &lt;th&gt;Details&lt;/th&gt;
                                  &lt;th&gt;Retailers&lt;/th&gt;
                                  &lt;th&gt;Price&lt;/th&gt;
                                  &lt;th&gt;Buy&lt;/th&gt;
                         &lt;/tr&gt;
                      &lt;/thead&gt;
                  &lt;/div&gt;&lt;?php
   error_reporting(0);
   mysql_connect("localhost", "root", "") or die("Error connecting to database: ".mysql_error());
   mysql_select_db("wordpress") or die(mysql_error());
       ?&gt;&lt;?php $query = $_POST['query'];  $query = htmlspecialchars($query); 
  $query = mysql_real_escape_string($query);
  $raw_results=mysql_query("select feed_product_image,feed_product_name,price,deeplink,image from wp_pc_products_merchants e,wp_pc_products w where e.slug=w.id_merchant and feed_product_name LIKE '%".$query."%'") or die(mysql_error());
       if(mysql_num_rows($raw_results) &gt; 0)
      {
      while($results = mysql_fetch_array($raw_results))
          { ?&gt;&lt;div class="input-group col-sm-8" style="text-align:center;margin-top:10px;"&gt;&lt;tbody&gt;
  
                        &lt;tr&gt;
                           &lt;td&gt;&lt;img src = "&lt;?php  echo $results['feed_product_image'];  ?&gt;"  style="object-fit:contain;height:70px;width:100px;" /&gt;&lt;/td&gt;
                           &lt;td&gt;&lt;?php  echo "&lt;p&gt;".$results['feed_product_name']. "&lt;/p&gt;" ; ?&gt;&lt;/td&gt;
                           &lt;td&gt;&lt;img src = "&lt;?php  echo $results['image'];  ?&gt;"  style="background-size:contain;height:40px;width:120px;"  /&gt;&lt;/td&gt;
                           &lt;td&gt;&lt;?php echo '&lt;i class="fa fa-inr"&gt;&amp;nbsp;'.$results['price']. '&lt;/i&gt;'.".00" ;   ?&gt;&lt;/td&gt;
                           &lt;td&gt;&lt;a href="&lt;?php  echo $results['deeplink'];  ?&gt;" style="background-color:#ff8c21;" class="btn btn-warning btn-md"&gt;Buy now&lt;/a&gt;&lt;/td&gt;
                       &lt;/tr&gt;
      &lt;/tbody&gt;
          &lt;/div&gt;  
  
  
             &lt;?php 
  
        }      
      }
      else
      { // if there is no matching rows do following
          echo "No results";
      }
  
  
  
  
  ?&gt;
  
      &lt;/div&gt;
      &lt;/form&gt;
      &lt;/div&gt;
  </code></pre>