현재 MySql의 정보를 가져 와서 해당 정보를 PDF로 변환하고 PHPmailer를 사용하여 이메일로 보내는 송장 스크립트를 작성 중입니다.FPDF & While 루프
내가 붙어있는 부분은 이걸 PDF로 변환하는 방법입니다. 다음 페이지로 orderid를 게시하여 PDF로 변환 할 수있게하고 싶습니다.
아래 도움말을 보려면 아래 스크립트를 첨부하십시오.
<?php
session_start();
$username = $_SESSION['username'];
$con = mysqli_connect('***', '***', '***', '***');
if (!isset($con)) {
die("Connection to Aurora System failed.");
}
$orderid = $_POST['order_id'];
?>
<!doctype html>
<html>
<body class="body page-orderview clearfix">
<div class="element"></div>
<p class="text text-1">SMKD Field Force</p>
<a href="front.php"><img class="image" src="images/smkd_logo.png"></a>
<p class="text text-2">Welcome</p>
<p class="text text-3">Order <?php echo "$orderid"; ?>
<table>
<tr>
<th>Product Title</th>
<th>Nicotine Strength</th>
<th>Quantity</th>
<th>Price (inc. VAT)</th>
</tr>
<?php
$query = "SELECT `product`, `variant`, `quantity` FROM orders_detail WHERE order_id = '$orderid'";
$result = mysqli_query($con, $query);
$quantitytotal = 0;
$quantityline = - 0;
while ($row = mysqli_fetch_assoc($result)) {
$product = $row['product'];
$stuff = $row['quantity'];
$variant = $row['variant'];
$linequantity = $stuff;
$quantitytotal += $stuff;
$pricequery = "SELECT product_price FROM products WHERE product_name = '$product'";
$priceresult = mysqli_query($con, $pricequery);
$pricetag = 0;
$priceline = 0;
while ($rowprice = mysqli_fetch_assoc($priceresult)) {
$price = $rowprice['product_price'];
$pricetag += $price;
$priceline = $price;
}
$linetotal = $priceline * $linequantity;
echo '<tr><td>' . $product .' </td> ' . '<td>' . $variant . '</td>' . ' <td> ' . $linequantity . '</td>' . '<td> £' . $linetotal . '</td> </tr>';
}
$total = $pricetag * $quantitytotal;
?>
<tr><td>Total Ex Vat:</td><td> Total Inc Vat:</td></tr>
<tr><td><?php echo "£" . ($total/1.2);?></td>
<td><?php echo "£" . $total; ?></td></tr>
</table>
</p><br>
<form method="post" action"pdfinvoice.php">
<input type="hidden" value="<?php echo $orderid; ?>" name="orderid">
</form>
Submit button goes here
</body>
</html>
전체 페이지를 PDF로 변환하는 것에 반대하지 않지만 FPDF에서는 가능하지 않습니다.
감사합니다. & 많은 감사!
https://github.com/mpdf/mpdf –