TCPDFを使用してpdfを作成しようとしていますが、pdfに何も表示されていません。検索後に呼び出されるデータは表示されません。 NB私はまた、2つのテーブル間の結合を使用しました。TCPDFを使用してpdfにデータを挿入する方法
<?php
ob_start();
function fetch_data(){
$output="";
if(isset($_POST["btnSearch"]))
{
if (isset($_POST['txtNameSearch'])){
$search = $_POST['txtNameSearch'];
$connection = mysqli_connect('localhost', 'root', '', 'bookstore');
$sql="SELECT * FROM order_details right join tblproduct on
order_details.prod_id=tblproduct.prod_id WHERE id_login = $search";
$Joined_records=mysqli_query($connection,$sql);
while ($row=mysqli_fetch_assoc($Joined_records)){
$output .='
<tr>
<td>'.$row["order_details_id"].'</td>
<td>'.$row["order_id"].'</td>
<td>'.$row["prod_id"].'</td>
<td>'.$row["id_login"].'</td>
<td>'.$row["quantity"].'</td>
<td>'.$row["price_per_unit"].'</td>
<td>'.$row["prod_name"].'</td>
<td>'.$row["prod_descr"].'</td>
<td>'.$row["prod_cat"].'</td>
<td>'.$row["prod_price"].'</td>
<td>'.$row["prod_quan"].'</td>
</tr>
';
}
return $output;
}
}
}
if(isset($_POST["create_pdf"]))
{
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("product sales for a specific customerproduct sales for a
specific customer");
$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"> product sales for a specific customer </h3>
<table border="1" cellspacing="0" cellpadding="5">
<tr>
<th width=9%>order_details_id</th>
<th width=9%>order_id</th>
<th width=9%>product_id</th>
<th width=9%>id_login</th>
<th width=9%>quanitity</th>
<th width=9%>price_per_unit</th>
<th width=9%>prod_name</th>
<th width=25%>prod_descr</th>
<th width=9%>prod_cat</th>
<th width=9%>prod_price</th>
<th width=9%>prod_quan</th>
</tr>
';
$content .= fetch_data();
$content .= '</table>';
$obj_pdf->writeHTML($content);
$obj_pdf->Output("sample.pdf","I");
}
?>
<html>
<head>
<title>product sales for a specific customer</title>
<link rel="stylesheet" type="text/css" href="css/style.css" />
</head>
<body>
<h3 align="center"> Please Search for a specific customer you want to see sales for: </h3>
<br />
<form method="POST" action="index.php">
<input type="text" name="txtNameSearch" />
<input class="src_btn" type="submit" name="btnSearch" value="Search" />
</form>
<table width="800" border="1" cellpadding="1" cellspacing="1">
<tr>
<th>Order Details Id</th>
<th>Order ID</th>
<th>Product Id</th>
<th>Login ID</th>
<th>Quantity</th>
<th>Product Price per unit</th>
<th>Product Name</th>
<th>Product Descrp</th>
<th>Genre</th>
<th>Price</th>
<th>Quantity Sold</th>
</tr>
<form method="post">
<input type="submit" name="create_pdf" class="btn btn-
danger" value="create_pdf" />
</form>
<?php
echo fetch_data();
?>
私は質問を言い換えてください。 –
私の編集した答えを見てください。 –
この@MOHAMMEDAMEENに関する最新情報はありますか?私の問題を理解できなかった場合は、あなたの最初の質問が変更されたように見えるかもしれませんが、あなたの質問をきれいにして言い換えてください。 –