我创建了test1.php视图,该文件在提交按钮上包含重定向到checkpdf.php的表单中的输入值,用于创建pdf发票文件。但是出现此错误。怎么解决呢在检查pdf文件中获取所有正确的值而不生成pdf进行测试。 代码中的以下内容位于checkpdf.php中 please check image 这是我的test1.php视图页面
<?php
include 'config.php';
$query= "select * from qaote_dets";
if ($result=mysqli_query($conn,$query))
{
// Fetch one and one row
// Free result set
?>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
</head>
<body>
<div class="col-md-12">
<h1>Test </h1>
</div>
<div class="col-md-12" style="padding-top: 32px;">
<div class="col-md-8" style="float:left;">
<form action='checkpdf.php' method='POST' id='quatepdf'>
<table border="1">
<tr>
<th>#sr. no</th>
<th>item no.</th>
<th>item description</th>
<th>quantity</th>
<th>price/unit</th>
</tr>
<?php
$i = 1;
while ($row=mysqli_fetch_row($result))
{
?>
<tr id="row<?php echo $i ?>">
<td>
<input type="checkbox" class="check1" id="checkdet<?php echo $i;?>" name="checkboxtest[]" value="<?php echo $row[1]; ?>">
</td>
<td>
<input type="text" class="form-control text1" id="text1" value="<?php echo $row[1]; ?> " name='item_name[]'><br>
</td>
<td>
<textarea class="form-control item desc" value="" name='item_desc[]'><?php echo $row[2];?></textarea>
</td>
<td>
<input type="text" class="form-control quantity<?php echo $i;?>" value="1" name='qty[]'>
</td>
<td>
<input type="text" class="form-control amnt<?php echo $i;?> " readonly="" name='amnt[]' value="<?php echo $row[3];?>" >
<input type="hidden" class="service<?php echo $i ?>" value="<?php echo $row[4];?>" name='service[]'>
</td>
</tr>
<?php $i++; } mysqli_data_seek($result, 0);?>
<tr>
<td>
<th colspan="3">Total</th>
</td>
<td>
<input type="text" readonly="" id="totamnt" value="" name="tolval">
</td>
</tr>
<tr>
<td>
<th colspan="3">GSt(18%)</th>
</td>
<td>
<input type="text" readonly="" id="gst" value="" name="gstamt">
</td>
</tr>
<tr>
<td>
<th colspan="3">Final Amount</th>
</td>
<td>
<input type="text" readonly="" id="finamt" value="" name="finalamt">
</td>
</tr>
</table>
<div class="col-md-12" style="padding-top:10px;">
<div class="col-md-4" style="float: left;">
<input type="button" value="Calculate" class="btn-success" id="Calculate">
</div>
<div class="col-md-4" style="float: left;">
<input type="submit" value="Genrate Pdf" class="btn-success" name="pdfbtn">
</div>
<div class="col-md-4"></div>
</div>
</form>
</div>
<div class="col-md-4" style="float:left;">
<table border = "1">
<tr>
<th>add product</th>
<th>#Sr no.</th>
<th>Item code</th>
<th>amount</th>
<th>installation charges</th>
</tr>
<?php
$i =1;
while ($row=mysqli_fetch_row($result))
{
?>
<tr>
<td>
<input type="checkbox" class="" name="" id="check<?php echo $i?>">
</td>
<td>
<span class=""> <?php echo $i;?></span>
</td>
<td>
<span class=""><?php echo $row[1];?> </span>
</td>
<td>
<span class=""><?php echo $row[3];?> </span>
</td>
<td>
<span class=""><?php echo $row[4];?></span>
</td>
</tr>
<?php $i++; } ?>
</table>
</div>
</div>
</body>
</html>
<?php
mysqli_free_result($result);
}
?>
这是我重定向的checkpdf.php页面
<?php
include("mpdf60/mpdf.php");
$logoFile = 'ssi.jpg';
$logoXPos = 10;
$logoYPos = 10;
$logoWidth = '40px';
/* valus checked */
$item_code = $_POST['item_name'];
$item_desc = $_POST['item_desc'];
$quantity = $_POST['qty'];
$price = $_POST['amnt'];
$service = $_POST['service'];
$totamt = $_POST['tolval'];
$gst = $_POST['gstamt'];
$final = $_POST['finalamt'];
/* close */
$pdf = new mPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
//$pdf->Cell(40,10,'Hello World!');
$pdf->Image( $logoFile, $logoXPos, $logoYPos, $logoWidth );
$pdf->WriteFixedPosHTML("<span> abc infotech<span>",550, 20, 50, 90, 'auto');
$pdf->WriteFixedPosHTML("<span> A-103, trimak co-op soc<span>",550, 25, 50, 90, 'auto');
$pdf->WriteFixedPosHTML("<span> vani ali, gandhi chowk<span>",550, 30, 50, 90, 'auto');
$pdf->WriteFixedPosHTML("<span> Badlapur(e) 421503<span>",550, 35, 50, 90, 'auto');
$pdf->WriteFixedPosHTML("<hr>",00, 44, 550, 55, 'auto');
$pdf->WriteFixedPosHTML("<div style='background-color:orange;'><span style='color:#000'>abc infotrch<span> <span stye='color:#000';>abcinfo@gmail.com</span> <span style='color:#000;'>contact : 9998898989</span></div>",50, 755, 1000, 5, 'auto');
// if(isset($_POST['pdfbtn'])){
if(!empty($_POST['checkboxtest'])) {
$htmlTable='<table border="1">
<tr>
<th>S. No.</th>
<th>Item code</th>
<th>Description</th>
<th>quantity</td>
<th>amount</th>
<th>service</th>
</tr>';
$i=1;
foreach($_POST['checkboxtest'] as $check) {
$htmlTable.='<tr>';
$htmlTable.='<td>'.$i;
$htmlTable.='</td>';
$htmlTable.='<td>'.$item_code[$i];
$htmlTable.='</td>';
$htmlTable.='<td>'. $item_desc[$i];
$htmlTable.='</td>';
$htmlTable.='<td>'.$quantity[$i];
$htmlTable.='</td>';
$htmlTable.='<td>'.$price[$i];;
$htmlTable.='</td>';
$htmlTable.='<td>'.$service[$i];
$htmlTable.='</td>';
$i++;
}
$htmlTable.='</tr>' ;
$htmlTable.='<tr> <td colspan=3> Total Amount </td>' ;
$htmlTable.='</tr> <td >'.$totamt.'</td></tr>' ;
$htmlTable.='<tr> <td colspan=3>Gst(18%) </td>' ;
$htmlTable.='</tr> <td >'.$gst.'</td></tr>' ;
$htmlTable.='<tr> <td colspan=3> Final Amount </td>' ;
$htmlTable.='</tr> <td >'.$final.'</td></tr>' ;
$htmlTable.='</table>';
}
// }
$pdf->WriteHTML($htmlTable);
$pdf->Output();
?>