Printing data using php getting blank page in print preview

Hi i am trying to print the data of the page but in print preview it is displaying a blank page not displaying any records.Clicking on the print button it is opening a print preview mode but not getting any data in that displaying a blank page in print preview.Can anyone help me this one.Thanks in advance.Here is the code which i have written for printing a page.I have used ajax search functionality for displaying the record if we search by name.

<div class="sign-u">                    
                        <input type="text" name="search_text"  id="search_text"  placeholder="Search Patients Details By Name"/>
                    </div>
                    <br/>

                    <input type="button" value="print" onclick="PrintDiv();" />
                    <div id="divToPrint" style="display:none;">
       <div style="width:200px;height:300px;background-color:teal;">
       <?php echo $output; ?>      
     </div>
   </div>
                    <div id="result"></div>         

    <script type="text/javascript">     
               function PrintDiv() {    
   var divToPrint = document.getElementById('divToPrint');
   var popupWin = window.open('', '_blank', 'width=300,height=300');
   popupWin.document.open();
   popupWin.document.write('<html><body onload="window.print()">' + divToPrint.innerHTML + '</html>');
    popupWin.document.close();
        }
   </script> 

 <script type="text/javascript">
  $(document).ready(function(){
 load_data();
 function load_data(query)
 {
 $.ajax({
url:"searchpatient.php",
method:"POST",
data:{query:query},
success:function(data)
{
$('#result').html(data);
}
});
}
  $('#search_text').keyup(function(){
 var search = $(this).val();
 if(search != '')
 {
load_data(search);
 }
 else
 {
 load_data();
 }
});
});
</script>  

Searchpatient.php

<?php
 include 'includes/db.php';
 $output = '';
 if(isset($_POST["query"]))
 {
 $search = mysqli_real_escape_string($conn, $_POST["query"]);
 $query = "
  SELECT * FROM appointment 
 WHERE first_name LIKE '$search%'  
 ";
 }
else
{
$query = "
SELECT * FROM appointment  ORDER BY date DESC
";
}
$result = mysqli_query($conn, $query);
if(mysqli_num_rows($result) > 0)
{   
$output .='<h2>All Patient Records</h2>';
$output .= '
<div class="table-responsive">
 <table class="table">
 <thead>
    <tr>
        <th>#</th>
        <th>Name</th>
        <th>Gender</th>
        <th>Department</th>
        <th>Phonenumber</th>
        <th>Date</th>   
        <th>Modify</th>         
    </tr>
</thead>
';
 while($row = mysqli_fetch_array($result))
 {
    $output .= '
   <tr>
                                        <td>'. ++$counter. '</td>
                                        <td>' . $row['first_name'].' </td>
                                        <td>' . $row['gender'].'</td>
                                        <td>' . $row['department'].'</td>
                                        <td>' . $row['phone_no'].'</td>                                         
                                        <td>' . $row['date'].'</td>                                         
                                         <td><a class="buttons edit" href="editallpatient.php?id=' .$row['appoint_id'] .'"><i class="fa fa-pencil"></i></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                        <a class="buttons delete" href="deleteall.php?id=' .$row['appoint_id'] .'"><i class="fa fa-trash"> </i></a></td>                                      
                                    </tr>
 ';
 }
echo $output;
}
 else
  {
 echo 'Data Not Found';
 }

?>