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….
If any one know means kindly give your answers. hope you guys got my ques..
Thanks in Advance.
Update : here is my script pdf.php
<?php
include ('connection.php');
require('fpdf.php');
$joined = $_GET['joined'];
list($ZoneNo, $InstituteNo, $Year) = split('[,]', $joined);
//echo "ZoneNo: $ZoneNo; Institute: $InstituteNo; Year: $Year<br />\n";
$pdf=new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',10);
$pdf->Ln();
$pdf->Ln();
$pdf->SetFont('Arial','B',10);
$pdf->Cell(20,15,"No");
$pdf->Cell(50,15,"Institute Name");
$pdf->Cell(50,15,"Course Name");
$pdf->Cell(50,15,"No. Of Students");
$pdf->Cell(50,15,"Year");
$pdf->Ln();
$pdf->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->Cell(20,15,"{$No}");
$pdf->Cell(50,15,"{$InstituteName}");
$pdf->Cell(50,15,"{$CourseName}");
$pdf->Cell(50,15,"{$Total}");
$pdf->Cell(50,15,"{$Year}");
}
$pdf->Output();
?>
note you guys here am getting only the output as
No InstituteName Course name No. of students Year
can you explain it now guys????
Guys Check this link http://www.fpdf.de/downloads/addons/30/ if you have problems
try FPDF liberary as mentioned by diEcho above. You can find the Tutorials on their website. Here’s a complete example of exporting data from mysql using the FPDF:
http://www.fpdf.de/downloads/addons/30/
Also here:
http://www.weberdev.com/get_example-3720.html
Hope it helps