我想按ID打印特定发票 例如,我只想通过单击打印按钮打印已在数据库中注册的客户发票 我的代码
我是编程的新手,我不知道代码是否有错误,但我很好地与我合作并显示客户的发票,但我想打印它们
<?php
define("ROW_PER_PAGE",5);
include 'db.php';?>
<html dir="rtl">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Report List</title>
<link rel="stylesheet" type="text/css" href="assets/fontawesome.min.css">
<link rel="stylesheet" type="text/css" href="assets/materialize.min.css">
</head>
<body>
<?php
$search_keyword = '';
if(!empty($_POST['search']['keyword'])) {
$search_keyword = $_POST['search']['keyword'];
}
$sql = 'SELECT * FROM rp_info WHERE rp_rnumber LIKE :keyword OR rp_name LIKE :keyword OR rp_phonenumber LIKE :keyword ORDER BY rp_id DESC ';
$per_page_html = '';
$page = 1;
$start=0;
if(!empty($_POST["page"])) {
$page = $_POST["page"];
$start=($page-1) * ROW_PER_PAGE;
}
$limit=" limit " . $start . "," . ROW_PER_PAGE;
$pagination_statement = $pdo_conn->prepare($sql);
$pagination_statement->bindValue(':keyword', '%' . $search_keyword . '%', PDO::PARAM_STR);
$pagination_statement->execute();
$row_count = $pagination_statement->rowCount();
if(!empty($row_count)){
$per_page_html .= "<div style='text-align:center;margin:20px 0px;'>";
$page_count=ceil($row_count/ROW_PER_PAGE);
if($page_count>1) {
for($i=1;$i<=$page_count;$i++){
if($i==$page){
$per_page_html .= '<input type="submit" name="page" value="' . $i . '" class="btn-page current" />';
} else {
$per_page_html .= '<input type="submit" name="page" value="' . $i . '" class="btn-page" />';
}
}
}
$per_page_html .= "</div>";
}
$query = $sql.$limit;
$pdo_statement = $pdo_conn->prepare($query);
$pdo_statement->bindValue(':keyword', '%' . $search_keyword . '%', PDO::PARAM_STR);
$pdo_statement->execute();
$result = $pdo_statement->fetchAll(); ?>
<div class="striped">
<form name='frmSearch' action='' method='post'>
<div style='text-align:center;' '>
<div >
<label for="search">Search</label><br>
<input id="search" class="validate" placeholder="Enter" type="text" name="search[keyword]" value="<?php echo $search_keyword; ?>" maxlength="25" style="margin-right: %50;width: 25%;background: #f5f5f5 url(images/sc.png) no-repeat center left 7px;">
</div>
<table class="striped">
<thead>
<tr>
<th>iD</th>
<th>Name</th>
<th>Unit</th>
<th>Rank</th>
<th>Print</th>
</tr>
</thead>
<tbody id='table-body '>
<?php
if(!empty($result)) {
foreach($result as $row) {
?>
<tr>
<td><?php echo $row['rp_id'];?></td>
<td><?php echo $row['rp_name'];?></td>
<td><?php echo $row['rp_phonenumber'];?></td>
<td><?php echo $row['rp_rank'];?></td>
<td><?php echo $row['rp_unit'];?></td>
<td><input type="submit" name="page" value="PRINT PDF" class="btn-page current" /></td>
</tr>
<?php
}
}
?>
</tbody>
</table>
<?php echo $per_page_html; ?>
</form>
</body>
</html>