<?php
mysql_connect('localhost','root','root');
mysql_select_db('project');
$dbname="project"
require('fpdf.php');
//Connect to your database
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
//Create new pdf file
$pdf=new FPDF();
//Open file
$pdf->Open();
//Disable automatic page break
//Add first page
$pdf->AddPage();
//set initial y axis position per page
$y_axis_initial = 25;
$pdf->SetX(25);
$pdf->Cell(30, 6, 'id', 1, 0, 'L', 1);
$pdf->Cell(30, 6, 'Studentid', 1, 0, 'R', 1);
//Select the Products you want to show in your PDF file
$result=mysql_query('select * from add_marks');
//initialize counter
//Set maximum rows per page
//Set Row Height
while($row = mysql_fetch_array($result))
{
//print column titles for the current page
$pdf->SetY($y_axis_initial);
$pdf->SetX(25);
$pdf->Cell(30, 6, 'id', 1, 0, 'L', 1);
$pdf->Cell(30, 6, 'Studentid', 1, 0, 'R', 1);
//Go to next row
$id = $row['id'];
$Studentid = $row['Studentid'];
//Go to next row
}
//Create file
$pdf->Output();
?>
<?php
$result = mysql_query("SHOW COLUMNS FROM add_marks");
$i = 0;
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_assoc($result))
{
$csv_output .='"'.$row['id'].'","';
$i++;}
}
$csv_output .= "n";
$values = mysql_query("SELECT * FROM add_marks");
while ($rowr = mysql_fetch_row($values)) {
for ($j=0;$j<$i;$j++) {
$csv_output .= $rowr[$j].",";
}
$csv_output .= "n";
}
$filename = $file."_".date("d-m-Y_H-i",time());
header("Content-type: application/pdf");
header("Content-disposition: pdf" . date("Y-m-d") . ".pdf");
header( "Content-disposition: filename=".$viewresults1.php".pdf");
print $csv_output;
exit;
?>
**jst help me to convert database record to pdf file format and then display the pdf file on the form i hv tried the abv cord bt it does nt work db table is the same as i mentioned earlier pls give me the result as fst as possible *