工资单打印相同的数据 [英] Salary sheet printing same data

查看:96
本文介绍了工资单打印相同的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在开发一个工资单项目,我在xampp服务器上用php,html,js和mysql编写代码。我有一个工资表代码,需要以pdf格式打印每个员工,其名称为pdf文件名。

运行php页面js代码自动触发并生成pdf文件但问题是第一名员工的工资数据打印在每个工资单上但是

文件名随每个pdf而变化。

例如:

1st emp名字是rajesh rao,第二个emp名字是a.ghosh。

现在当我打印工作表时,为这两个员工创建了2个pdf文件,其名称为文件名,但工资数据没有变化在第二张床单上/



任何帮助将不胜感激



我尝试过的:



< HTML>

< HEAD>

< TITLE>薪水工作表< / TITLE>

< meta name =viewportcontent =width = device-width,initial-scale = 1>

< link rel =stylesheethref =pure-blog / css / home.css/>

< link rel =stylesheethref =pure-blog / css / pure-min.css/>

< link rel =stylesheethref =pure- blog / css / pure-u.css/>

< link rel =stylesheethref =pure-blog / css / pure-form.css/>

< link rel =stylesheethref =pure-blog / css / pure-menu.css/>

< link rel =stylesheethref = pure-blog / css / pure-table.css/>

< / HEAD>

< BODY>

< ?php

包含connect.php;

$ cde = 1;

while($ cde< 3){

$ mysql =SELECT * FROM emp_ndata WHERE ID ='$ cde';

$ myquery = mysqli_query($ con,$ mysql);

if(!$ myquery){

die('无法获取数据:'。mysql_error());

}

$ row = mysqli_fetch_array($ myquery,MYSQLI_ASSOC);

?>

< div id =pdataclass =printArea>

< div class =pure-imgstyle =text-align:left>

< img src =pure-blog / img / companyLogoFull-pdf .png>

< / div>



< table class =table_for_showdata table_for_showdata_small>

< tr>

< th colspan =2>

工资表< b class =table_for_showdata_lg>

<?php echo $ row ['Emp_Name']; ?>< / B个:&安培; NBSP; <?php echo $ row ['Emp_psmonth']; ?>&安培; NBSP; ,& nbsp;<?php echo $ row ['Emp_psyear']; ?>

< / th>

< / tr>



< tr>

< td> Emp-Code< / td>

< td><?php echo $ row ['Emp_ID']; ?>< / td>

< / tr>

< tr>

< td>名称< / td>

< td><?php echo $ row ['Emp_Designation']; ?>< / td>

< / tr>



< tr>

< ; th colspan =2> EARNINGS< / th>

< / tr>



< tr>

< td> Basic< / td>

< td><?php echo round($ row ['Emp_Basic'])。。00; ?>< / td>

< / tr>



< tr>

< ; td>房屋租金津贴< / td>

< td><?php echo round($ row ['Emp_HRA'])。。00; ?>< / td>

< / tr>



< tr>

< ;> DEDUCTIONS< / th>

< th>& nbsp;< / th>

< / tr>



< tr>

< td>专业税< / td>

< td><?php echo $ row ['Emp_Proffessional_Tax']。。00; ?>< / td>

< / tr>



< tr>

< ; td> Provident Fund< / td>

< td><?php echo $ row ['Emp_Provident_Fund']。。00; ?>< / td>

< / tr>



< tr>

< ; &&;& nbsp;< / th>

< th>& nbsp;< / th>

< / tr>



< tr>

< td class =tab_head_blue>< b> TOTAL PAY:< / td>

< td style =font-size:18px>< b> Rs。<?php echo $ row ['Emp_Total_Pay']。。00; ?>< / b>< / td>

< / tr>



< / table>

< / div>

< script type =text / javascript>

function printDiv(){

var divToPrint = document.getElementById('pdata');

var popupWin = window.open('','_ blank','width = 1100,height = 400');

popupWin.document.open();

document.title =<?php echo $ row ['Emp_Name'];?>;

popupWin.document.write('< html>< head>< title>'+ document.title +'< / title>');

popupWin.document.write(' < html>< body onload =window.print()>'+ divToPrint.innerHTML +'< / html>');

popupWin.document.close(); < br $>
}

< / script>



< script>

printDiv ();

< / script>

<?php

$ GLOBALS [ cde'] ++;

}

?>



< / BODY>

< / HTML>

解决方案

cde = 1;

while(


< blockquote> cde< 3){


mysql =SELECT * FROM emp_ndata WHERE ID ='


Hi I am working on a payroll project and I am coding with php,html,js and mysql on xampp server. I have a salary sheet code which needs to be printed in pdf format for each employee with their names as the pdf filename.
on running the php page the js code triggers automatically and generates pdf files but the problem is the salary data of the first employee is printed on every payslip but
The filename changes with every pdf.
for example :
1st emp name is rajesh rao, 2nd emp name is a.ghosh.
now when I print the sheets, then 2 pdf files are created for these 2 employees with their names as filenames but the salary data is not changing on the 2nd emp sheet/

Any Help will be appreciated

What I have tried:

<HTML>
<HEAD>
<TITLE>Salary Sheet</TITLE>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="pure-blog/css/home.css" />
<link rel="stylesheet" href="pure-blog/css/pure-min.css" />
<link rel="stylesheet" href="pure-blog/css/pure-u.css" />
<link rel="stylesheet" href="pure-blog/css/pure-form.css" />
<link rel="stylesheet" href="pure-blog/css/pure-menu.css" />
<link rel="stylesheet" href="pure-blog/css/pure-table.css" />
</HEAD>
<BODY>
<?php
include "connect.php";
$cde = 1;
while ($cde < 3) {
$mysql = "SELECT * FROM emp_ndata WHERE ID = '$cde' ";
$myquery = mysqli_query($con, $mysql);
if(! $myquery ) {
die('Could not get data: ' . mysql_error());
}
$row = mysqli_fetch_array($myquery, MYSQLI_ASSOC);
?>
<div id="pdata" class="printArea">
<div class="pure-img" style="text-align:left">
<img src="pure-blog/img/companyLogoFull-pdf.png">
</div>

<table class="table_for_showdata table_for_showdata_small">
<tr>
<th colspan="2">
Salary Sheet of <b class="table_for_showdata_lg">
<?php echo $row['Emp_Name']; ?></b> :&nbsp; <?php echo $row ['Emp_psmonth']; ?>&nbsp; , &nbsp;<?php echo $row ['Emp_psyear']; ?>
</th>
</tr>

<tr>
<td>Emp-Code</td>
<td><?php echo $row['Emp_ID']; ?></td>
</tr>
<tr>
<td>Designation</td>
<td><?php echo $row['Emp_Designation']; ?></td>
</tr>

<tr>
<th colspan="2">EARNINGS</th>
</tr>

<tr>
<td >Basic</td>
<td><?php echo round($row ['Emp_Basic']).".00"; ?></td>
</tr>

<tr>
<td >House Rent Allowance</td>
<td><?php echo round($row ['Emp_HRA']).".00"; ?></td>
</tr>

<tr>
<th >DEDUCTIONS</th>
<th>&nbsp;</th>
</tr>

<tr>
<td >Professional Tax</td>
<td><?php echo $row ['Emp_Proffessional_Tax'].".00"; ?></td>
</tr>

<tr>
<td >Provident Fund</td>
<td><?php echo $row ['Emp_Provident_Fund'].".00"; ?></td>
</tr>

<tr>
<th >&nbsp;</th>
<th>&nbsp;</th>
</tr>

<tr>
<td class="tab_head_blue"><b>TOTAL PAY : </td>
<td style="font-size:18px"><b>Rs.<?php echo $row ['Emp_Total_Pay'].".00"; ?></b></td>
</tr>

</table>
</div>
<script type="text/javascript">
function printDiv() {
var divToPrint = document.getElementById('pdata');
var popupWin = window.open('', '_blank', 'width=1100,height=400');
popupWin.document.open();
document.title = "<?php echo $row['Emp_Name']; ?>";
popupWin.document.write('<html><head><title>' + document.title + '</title>');
popupWin.document.write('<html><body onload="window.print()">' + divToPrint.innerHTML + '</html>');
popupWin.document.close();
}
</script>

<script>
printDiv();
</script>
<?php
$GLOBALS['cde']++;
}
?>

</BODY>
</HTML>

解决方案

cde = 1;
while (


cde < 3) {


mysql = "SELECT * FROM emp_ndata WHERE ID = '


这篇关于工资单打印相同的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆