title: Using PHP with TCPDF to retrieve data(using mysql) from a database and show it as a .pdf file
body: <p>Actually I'm new to TCPDF. Can anyone help me to display the data as a <code>.pdf</code> file. I am using the following code and the data is being displayed as a general webpage. I want to display it in <code>.pdf</code> format.</p>
  
  <pre><code>require_once('../config/lang/eng.php')  
  require_once('../tcpdf.php')  
  error_reporting(E_ALL) ; ini_set('display_errors', '1');  
  $con=mysql_connect("localhost","root","");   
  if(!$con)  
  {  
   die('Could not connect: ' . mysql_error());  
  }   
  mysql_select_db("ef_kabaadkhana");  
  $result = mysql_query("SELECT form_id,partner_name FROM ef_form_master_v1");  
  if (($result))  
  {  
   echo "&lt;table width='100%'&gt;&lt;tr&gt;";  
   if (mysql_num_rows($result)&gt;0)    
  {  
  
         $i = 0;  
        while ($i &lt; mysql_num_fields($result))  
       {  
  
  echo "&lt;th&gt;". mysql_field_name($result, $i) . "&lt;/th&gt;";  
         $i++;  
      }  
      echo "&lt;/tr&gt;";  
   while ($rows = mysql_fetch_array($result,MYSQL_ASSOC))  
      {  
        echo "&lt;tr&gt;";  
        foreach ($rows as $data)  
        {  
          echo "&lt;td align='center'&gt;". $data . "&lt;/td&gt;";  
        }  
      }  
    }else{  
      echo "&lt;tr&gt;&lt;td colspan='" . ($i+1) . "'&gt;No Results found!&lt;/td&gt;&lt;/tr&gt;";  
    }  
    echo "&lt;/table&gt;";  
  }else{  
    echo "Error in running query :". mysql_error();  
  }  
  </code></pre>