title: Generate pdf from php(have to retrieve from mysql database)
body: <p>I have already created a report using list of data from my database. i have a button in that page "Click to generate Pdf". if i click that button the same report have to come as pdf report. now i need to convert that reports as PDF. i have googled past some days but i couldn't find the answers. all are saying and giving values directly into tables and they were generated it. But I need retrieve it directly from my database. i wanna to get it directly from queries....</p>
  
  <p>If any one know means kindly give your answers. hope you guys got my ques..</p>
  
  <p>Thanks in Advance.</p>
  
  <p>Update : here is my script pdf.php</p>
  
  <pre><code>&lt;?php
  include ('connection.php');
  require('fpdf.php');
  
  $joined = $_GET['joined'];
  list($ZoneNo, $InstituteNo, $Year) = split('[,]', $joined);
  //echo "ZoneNo: $ZoneNo; Institute: $InstituteNo; Year: $Year&lt;br /&gt;\n";
  
  $pdf=new FPDF();
  $pdf-&gt;AddPage();
  
  $pdf-&gt;SetFont('Arial','B',10);
  
  $pdf-&gt;Ln();
  $pdf-&gt;Ln();
  
  $pdf-&gt;SetFont('Arial','B',10);
  $pdf-&gt;Cell(20,15,"No");
  $pdf-&gt;Cell(50,15,"Institute Name");
  $pdf-&gt;Cell(50,15,"Course Name");
  $pdf-&gt;Cell(50,15,"No. Of Students");
  $pdf-&gt;Cell(50,15,"Year");
  $pdf-&gt;Ln();
  $pdf-&gt;Cell(450,3,"--------------------------------------------------------------------------------------------------------------------------------------------------------");
  
  
          $sql = "SELECT im.InstituteName,cm.CourseName,COUNT(sm.CourseNo),sm.Year FROM student_master sm,course_master cm,institute_master im WHERE ((sm.Year='".$Year."') AND (sm.InstituteNo='".$InstituteNo."') AND (sm.ZoneNo = '".$ZoneNo."')) AND (im.InstituteNo = sm.InstituteNo) AND (cm.CourseNo = sm.CourseNo) GROUP BY sm.CourseNo ORDER BY im.InstituteName,cm.CourseName";
          $result = mysql_query($sql);
          $No = 0;
          while($rows=mysql_fetch_array($result))
          {
              $No = $No + 1;
              $InstituteName = $rows[0];
              $CourseName = $rows[1];
              $Total = $rows[2];
              $Year = $rows[3];
              $pdf-&gt;Cell(20,15,"{$No}");
              $pdf-&gt;Cell(50,15,"{$InstituteName}");
              $pdf-&gt;Cell(50,15,"{$CourseName}");
              $pdf-&gt;Cell(50,15,"{$Total}");
              $pdf-&gt;Cell(50,15,"{$Year}");    
          }
  
  $pdf-&gt;Output();
  
  ?&gt;
  </code></pre>
  
  <p>note you guys here am getting only the output as </p>
  
  <h2>No  InstituteName   Course name    No. of students    Year</h2>
  
  <p>can you explain it now guys????</p>
  
  <p>Guys Check this link <a href="http://www.fpdf.de/downloads/addons/30/" rel="noreferrer">http://www.fpdf.de/downloads/addons/30/</a> if you have problems</p>