title: After button click I want to display the table and open new window
body: <p>Only after first execution table is displayed and also outs_print.php file is displayed in new tab when again executed outward_print.php file is displayed in same tab. </p>
  
  <p>I want table(outs_print.php file) to be displayed in new tab after button is clicked.</p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;body&gt;
    &lt;form name="out_print" action="out_print.php" method="post"&gt;
    &lt;table class="table_1"&gt;
    &lt;tr&gt;&lt;td&gt;&lt;label&gt;Date Range From&lt;/label&gt;&lt;/td&gt;
    &lt;td&gt;&lt;input type="date" name="from" /&gt;&lt;/td&gt;
  
    &lt;td&gt;&lt;label&gt;To&lt;/label&gt;&lt;/td&gt;
    &lt;td&gt;&lt;input type="date" name="to"/&gt;&lt;/td&gt;&lt;/tr&gt;
  
    &lt;tr&gt;&lt;td&gt;&lt;label&gt;Name&lt;/label&gt;&lt;/td&gt;
    &lt;td&gt;&lt;input type="text" name="name" /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
  
    &lt;input type="submit" name="submit" value="Search" onclick="myFunction();"  class="button3"/&gt;
    &lt;script&gt;
    function myFunction()
    {
      document.out_print.action = "outs_print.php";
      document.out_print.submit();                
    }
    &lt;/script&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>outs_print.php</p>
  
  <pre><code>&lt;?php
  
      $connection = mysql_connect("localhost", "root", "");
      $db = mysql_select_db("prs", $connection);
      if(isset($_POST['submit'])){    
      $name = $_POST['name'];
      $from = $_POST['from'];
      $to = $_POST['to'];
      if($name !=''||$from !=''||$to !='')
      {
  ?&gt;
  
  &lt;html&gt;
  &lt;body&gt;
      &lt;table border="1" bordercolor="#d6d6d6" class="tabl"&gt;
      &lt;thead bgcolor="#FAFAFA"&gt;
      &lt;tr&gt;
      &lt;th&gt;No&lt;/th&gt;
      &lt;th&gt;Date&lt;/th&gt;
      &lt;th&gt;Name&lt;/th&gt;
      &lt;th&gt;Price&lt;/th&gt;
      &lt;/tr&gt;  
      &lt;/thead&gt;
  
      &lt;tbody&gt;
  
      &lt;?php
          $sql = "SELECT * FROM out WHERE (date between '$from' and '$to') AND (name = '$name')";
          $records=mysql_query($sql);
          while($out=mysql_fetch_assoc($records))
          {
               echo "&lt;tr&gt;";
               echo "&lt;td&gt;".$out['no']."&lt;/td&gt;";
               echo "&lt;td&gt;".$out['date']."&lt;/td&gt;";
               echo "&lt;td&gt;".$out['name']."&lt;/td&gt;";
               echo "&lt;td&gt;".$out['price']."&lt;/td&gt;";
               echo "&lt;/tr&gt;";
          }
      ?&gt;
  
            &lt;script type="text/javascript"&gt;
              alert("Okay");
              var win = window.open("out_print.php", "out_print.php");
              win.focus();
            &lt;/script&gt;
  
      &lt;?php
         }
      }
      ?&gt;
  
      &lt;/tbody&gt;
      &lt;/table&gt; 
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>