title: printing only the selected data
body: <p>I am submitting the php form in the same page after displaying the data, i want to print it. I am able to do this. But i want to print only the resulted data which am displaying in a table. </p>
  
  <p>Here is my page</p>
  
  <pre><code>&lt;?php
  
  include ("include/dbconnect.php");
  include ("include/format.inc.php");
  
  ?&gt;
  &lt;script&gt;
  function myFunction()
  {
  window.print();
  }
  &lt;/script&gt;
  &lt;script src="htmlDatePicker.js" type="text/javascript"&gt;&lt;/script&gt;
      &lt;link href="htmlDatePicker.css" rel="stylesheet"&gt;
  
  
  &lt;script type="text/javascript"&gt;&lt;!--
          var today = new Date();
  
          DisablePast = false;
          range_start = new Date(today.getFullYear(),today.getMonth(),8);
          range_end = new Date(today.getFullYear(),today.getMonth(),5);
      --&gt;&lt;/script&gt;
  
  
  &lt;?php
  include ("include/header.inc.php");
  if(isset($_POST['submit']))
  {
  $date1 = $_POST['SelectedDate1'];
  $date2 = $_POST['SelectedDate1'];
  
  echo $date1;
  echo $date2;
  
  $sql = "select * from addressbook where lindate between '".$date1."' AND '".$date2."' ";
  $result = mysql_query($sql) or die (mysql_error());
  
  
      echo '&lt;table width="90%" align="center" cellpadding="0" border="0"&gt;';
  while($row = mysql_fetch_assoc($result))
  {
  echo '&lt;tr&gt;&lt;td&gt;' .$row['firstname']. $row['lastname']. '&lt;/td&gt;';
  echo '&lt;td&gt;' .$row['address']. '&lt;/td&gt;';
  echo '&lt;td&gt;' .$row['mobile']. '&lt;/td&gt;';
  echo '&lt;td&gt;' .$row['email']. '&lt;/td&gt;';
  echo '&lt;td&gt;' .$row['lindate']. '&lt;/td&gt;';
  echo '&lt;td&gt;' .$row['lintime']. '&lt;/td&gt;';
  echo '&lt;td&gt;' .$row['louttime']. '&lt;/td&gt;';
  echo '&lt;td&gt;' .$row['login']. '&lt;/td&gt;&lt;/tr&gt;';   
  
  }
  echo '&lt;/table&gt;';
  
  echo '&lt;button onclick="myFunction()"&gt;Print this page&lt;/button&gt;';
  }
  ?&gt;
  
  
  
  
  &lt;form action="&lt;?php echo $_SERVER["PHP_SELF"]; ?&gt;" method="post"&gt;
  Select Date Range:&lt;br /&gt;
  
  &lt;input type="text" placeholder="Click me!" name="SelectedDate1" id="SelectedDate" readonly onClick="GetDate(this);"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TO &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
  &lt;input type="text" placeholder="Click me!" name="SelectedDate2" id="SelectedDate" readonly onClick="GetDate(this);"&gt;
  
  
  
  &lt;input type="submit" name="submit" value="VIEW DATA" /&gt;
  &lt;/form&gt;
  
  &lt;?php include ("include/footer.inc.php");?&gt;
  </code></pre>
  
  <p>here i want to select only the data within the table. Please suggest me how to do it</p>