title: How can I create a PDF document from MySQL table data PHP
body: <p>I want to get data from the MySQL data base and make and create a PDF file of the data.</p>
  
  <p>Here is my code, it saving the PDF file but it can not be opened.</p>
  
  <pre><code>&lt;?php  
  $host = 'localhost';
  $user = 'root';
  $pass = 'xxxx';
  $db = 'db';
  
  $link = mysql_connect($host, $user, $pass) or die("Can not connect." . mysql_error());
  mysql_select_db($db) or die("Can not connect.");
  
  $query = "SELECT childID,sex from child ";  
  
  $result = mysql_query($query) or die('Error, query failed'); 
  
      while(mysql_fetch_array($result))  
      {  
          header("Content-length: $size"); 
          header("Content-type: $type"); 
          header("Content-Disposition: inline; filename=$username-$description.pdf"); 
      } 
      echo $content;
      mysql_close($link); 
      exit; 
  ?&gt;
  </code></pre>