tags:

views:

625

answers:

5

Hi I want to create an attandence list from the student's database in PDF using PHP. I want the columns student.name, student_id, student_rollno and a column for sign for signing to be made as table in pdf. How can I do this?

A: 

You could use the pdflib extension for php to do this.

Take a look at this tutorial for more details.

trex279
+1  A: 

I recommend TCPDF. http://www.tecnick.com/public/code/cp_dpage.php?aiocp_dp=tcpdf

It is a library that converts html to pdf, so you would run your db query in php and output the results in html. You can reference the php file that generates the html with a tcpdf function.

See examples here: http://www.tecnick.com/public/code/cp_dpage.php?aiocp_dp=tcpdf_examples

/////////////////////

You can also use the DOMPDF: http://www.digitaljunkies.ca/dompdf/ It is a little more recent than tcpdf and a little easier to use

superUntitled
+6  A: 

Well, this is a somewhat general question but I'll take the PDF part at least and offer up the following PHP class : http://www.tcpdf.org

This class works without having to enable the pdf extension on your server which is a huge benefit. But beyond that, it also supports simple HTML including the 'table' tag. If you know HTML, you can generate simple PDFs based on that knowledge.

Once you've retrieved the data from your database, it's really just a matter of assembling an HTML string:

$html = '<table>';
foreach ($results as $student) {
     $html .= '<tr><td>'.$student->name.'</td></tr>';
}
$html .= '</table>';

$tcpdf->writeHtml($html);

...etc.

A full fledged example of the writeHtml method can be found here: http://www.tecnick.com/pagefiles/tcpdf/example_006.phps

How you retrieve the data is very much dependent on your project.

Karim
This is the quick easy way - I have used this method and it works.
JasonMichael
A: 

You can use the PDF library in PHP

You will need to use the functions

string PDF_fit_table  ( resource $pdfdoc  , int $table  , float $llx  , float $lly  , float $urx  , float $ury  , string $optlist  )

int PDF_add_table_cell  ( resource $pdfdoc  , int $table  , int $column  , int $row  , string $text  , string $optlist  )

you can also try FPDF, Check out this tutorial. Basically, you need to output your database results in the form of a table.

Other Alternatives : TCPDF, EZPDF

tHeSiD
A: 

go for FPDF, http://www.fpdf.org/ - the best thing that is there...

dusoft