i got an error of undefined index a b d1 d2 when converting to pdf file and dept column is not displayed here is the code thankyou
<?php
function fetch_data()
{
$output = '';
$connect = mysqli_connect("localhost", "root", "", "aeis");
$a=$_POST['a'];
$b=$_POST['b'];
$from=date('Y-m-d',strtotime($_POST['d1']));
$to=date('Y-m-d',strtotime($_POST['d2']));
$sql = "SELECT t1.fid,s1.name,s1.dept,t1.date,t1.board,t1.time FROM sample s1,adinvglltn t1 where t1.fid=s1.fid and dept='$a'and board='$b' and date between '$from' and '$to' ORDER BY date ASC";
$result = mysqli_query($connect, $sql);
while($row = mysqli_fetch_array($result))
{
$output .= '<tr>
<td><input type="text" value="'.$row["fid"].'"></td>
<td><input type="text" value="'.$row["name"].'"></td>
<td<input type="text" value="'.$row["dept"].'"></td>
<td><input type="text" value="'.$row["date"].'"></td>
<td><input type="text" value="'.$row["board"].'"></td>
<td><input type="text" value="'.$row["time"].'"></td>
</tr>';
}
return $output;
}
if(isset($_POST["create_pdf"]))
{ ob_start();
require_once('tcpdf/tcpdf.php');
$obj_pdf = new TCPDF('P', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$obj_pdf->SetCreator(PDF_CREATOR);
$obj_pdf->SetTitle("Export HTML Table data to PDF ");
$obj_pdf->SetHeaderData('', '', PDF_HEADER_TITLE, PDF_HEADER_STRING);
$obj_pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$obj_pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
$obj_pdf->SetDefaultMonospacedFont('helvetica');
$obj_pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$obj_pdf->SetMargins(PDF_MARGIN_LEFT, '5', PDF_MARGIN_RIGHT);
$obj_pdf->setPrintHeader(false);
$obj_pdf->setPrintFooter(false);
$obj_pdf->SetAutoPageBreak(TRUE, 10);
$obj_pdf->SetFont('helvetica', '', 12);
$obj_pdf->AddPage();
$content = '';
$content .= '
<h3 align="center">Export HTML Table data to PDF </h3><br /><br />
<table border="1" cellspacing="0" cellpadding="5">
<tr>
<th width="10%">FID</th>
<th width="40%">NAME</th>
<th width="40%">DEPT</th>
<th width="10%">DATE</th>
<th width="10%">BOARD</th>
<th width="10%">TIME</th>
</tr>
';
$content .= fetch_data();
$content .= '</table>';
$obj_pdf->writeHTML($content);
ob_end_clean();
$obj_pdf->Output($_SERVER['DOCUMENT_ROOT'] . 'sample.pdf', 'F');
}
?>
<!DOCTYPE html>
<html>
<head>
<title> Export HTML Table data to PDF </title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
</head>
<body>
<br /><br />
<div class="container" style="width:700px;">
<h3 align="center">Export HTML Table data to PDF </h3><br />
<div class="table-responsive">
<table class="table table-bordered">
<tr>
<th width="5%">FID</th>
<th width="30%">NAME</th>
<th width="10%">DEPT</th>
<th width="45%">DATE</th>
<th width="45%">BOARD</th>
<th width="45%">TIME</th>
</tr>
<?php
echo fetch_data();
?>
</table>
<br />
<form method="post">
<input type="submit" name="create_pdf" class="btn btn-danger" value="Create PDF" />
</form>
</div>
</div>
</body>
</html
i got an tcpdf error please help me to solve this problem.actually i send data from html page to php page the the output is displayed after that i want to create a pdf for the output. php variables are not taken when converting to pdf