我有以下代码
<?php
ob_start();
include '../connection.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Easy Installment Motorcycle Scheme Haripur</title>
以下代码打印此页
<script type="text/javascript">
function printpage()
{
window.print();
}
</script>
</head>
<body onload="printpage()">
<div style="width:500px; margin-left:50px">
<?php
$sSql="SELECT * FROM landing_page WHERE status='active'";
$result=mysqli_query($con,$sSql);
if(!$result){
die(mysqli_error($con));
}
$row=mysqli_fetch_array($result);
?>
<h2 style="text-align:center">Receipt For <?php echo $row['schemeName'];?></h2>
在以下行中我想获得收据编号,该编号将使用php javascript或html
自动生成打印函数调用的任何位置<h3>Receipt No: </h3>
<?php
$sSql="SELECT * FROM draw_date_time";
$result=mysqli_query($con,$sSql);
if(!$result){
die(mysqli_error($con));
}
$row=mysqli_fetch_array($result);
?>
<h3>Draw Date: <u><?php echo $row['date_of_draw'];?></u> Draw Time: <u><?php echo $row['time_of_draw'];?></u> Draw Place: <u><?php echo $row['draw_address'];?></u></h3>
<?php
$reg_number=$_POST['reg_number'];
$month=date('Y-m-d',strtotime($_POST['month']));
$sSql="SELECT *
FROM users u LEFT JOIN
installments i
ON u.id = i.fk_users_id
WHERE u.reg_number = '$reg_number' AND i.month='$month'
LIMIT 0 , 30";
$result=mysqli_query($con,$sSql);
if(!$result){
die(mysqli_error($con));
}
$row=mysqli_fetch_array($result);
?>
<h2>Memebership No: <u><?php echo ucfirst($row['reg_number']);?></u></h2>
<table width="500" border="1" style="text-align:left">
<tr>
<th scope="row">Memeber Name</th>
<td><?php echo ucfirst($row['user_name']);?></td>
<th scope="row">Father Name</th>
<td><?php echo ucfirst($row['father_name']);?></td>
</tr>
<tr>
<th scope="row">Phone No</th>
<td><?php echo $row['phone'];?></td>
<th scope="row">CNIC No</th>
<td><?php echo $row['cnic'];?></td>
</tr>
<tr>
<th scope="row">Address</th>
<td><?php echo $row['address'];?></td>
<th scope="row">Receiver Name & address</th>
<td><?php echo $row['name_adrs_recvr'];?></td>
</tr>
<tr>
<th scope="row">Prv Arrear</th>
<td><?php echo $row['prv_arrear'];?></td>
<th scope="row">Amount</th>
<td><?php echo $row['amount'];?></td>
</tr>
<tr>
<th scope="row">Total</th>
<td><?php echo $row['total'];?></td>
<th scope="row">Receive</th>
<td><?php echo $row['receive'];?></td>
</tr>
<tr>
<th scope="row">Arrear</th>
<td><?php echo $row['arrear'];?></td>
<th scope="row">Date Receive</th>
<td><?php echo date('d-m-Y',strtotime($row['month']));?></td>
</tr>
</table>
<?php
$sql="SELECT * FROM landing_page WHERE status='active'";
$result=mysqli_query($con, $sql);
$row=mysqli_fetch_assoc($result);
?>
<fieldset>
<legend><img src="images/termsHead.png" style="float:right" /></legend>
<p><img src="../images/<?php echo $row['image2'];?>" width="400" height="300" /></p>
</fieldset>
</div>
</body>
</html>
请帮帮我。
答案 0 :(得分:0)
定义一个用于计数的变量,并在每次打印页面时将其增加一。
var printed = 0;
function printPage() {
print(); // "window." isn't needed
printed += 1; // Adds 1
alert(printed); // Alerts you overall how many times
};