Problem Convert HTML table to pdf using tcpdf
Posted: Sat Jul 07, 2012 7:25 am
Please help... I want to convert my php html table populated with data coming from mysql table to pdf using tcpdf classes, but i don't know how to start, below is the excerpt code, that i want to convert in pdf. I want the php html table code below convert to pdf once i click the convert to pdf link. Please help me on how to do this.
Thanks.
<?php
ob_start();
if (!isset($_SESSION)) {
session_start();
}
require 'con/db.php';
$sem = isset($_GET['sms']) ? mysql_real_escape_string(htmlentities(trim($_GET['sms']))) : "";
$sy = isset($_GET['syr']) ? mysql_real_escape_string(htmlentities(trim($_GET['syr']))) : "";
$sqlGetStud = @mysql_query("SELECT student.STUDENTNUM,student.FNAME, student.MNAME, student.LNAME,student.GENDER FROM student
INNER JOIN registration ON student.STUDENTNUM=registration.STUDENTNUM
WHERE registration.SEMESTER='$sem' AND registration.SY='$sy' ORDER BY student.LNAME,student.FNAME");
echo '<table width=75%>';
echo '<table border=1 width=95%>';
echo '<tr><td ><center><b>Name of Students</b></center><td ><center><b>ID NO.</b></center></td>';
while($rs = mysql_fetch_array($sqlGetStud)){
$name = $rs['LNAME'].',' .' ' .$rs['FNAME'] .' ' .$rs['MNAME'];
echo '<tr border=1><td>'.$name .'<td>'.$rs['STUDENTNUM'].'</td></tr>';
}
</table>
?>
Thanks.
<?php
ob_start();
if (!isset($_SESSION)) {
session_start();
}
require 'con/db.php';
$sem = isset($_GET['sms']) ? mysql_real_escape_string(htmlentities(trim($_GET['sms']))) : "";
$sy = isset($_GET['syr']) ? mysql_real_escape_string(htmlentities(trim($_GET['syr']))) : "";
$sqlGetStud = @mysql_query("SELECT student.STUDENTNUM,student.FNAME, student.MNAME, student.LNAME,student.GENDER FROM student
INNER JOIN registration ON student.STUDENTNUM=registration.STUDENTNUM
WHERE registration.SEMESTER='$sem' AND registration.SY='$sy' ORDER BY student.LNAME,student.FNAME");
echo '<table width=75%>';
echo '<table border=1 width=95%>';
echo '<tr><td ><center><b>Name of Students</b></center><td ><center><b>ID NO.</b></center></td>';
while($rs = mysql_fetch_array($sqlGetStud)){
$name = $rs['LNAME'].',' .' ' .$rs['FNAME'] .' ' .$rs['MNAME'];
echo '<tr border=1><td>'.$name .'<td>'.$rs['STUDENTNUM'].'</td></tr>';
}
</table>
?>