如何使用javaScript或jquery将一行附加到使用tcpdf在pdf中创建的表中?
我有一个表单,其中有两个字段:金额输入和提交按钮。提交此表单时,我希望数据存储在数据库中,并应使用tcpdf以pdf格式显示。每次我添加金额时,都应该将其追加到pdf中某一行的表中。怎么做??请帮我做这个 以下是提交金额的表格:如何使用javaScript或jquery将一行附加到使用tcpdf在pdf中创建的表中?,javascript,php,jquery,tcpdf,Javascript,Php,Jquery,Tcpdf,我有一个表单,其中有两个字段:金额输入和提交按钮。提交此表单时,我希望数据存储在数据库中,并应使用tcpdf以pdf格式显示。每次我添加金额时,都应该将其追加到pdf中某一行的表中。怎么做??请帮我做这个 以下是提交金额的表格: <div class="form-group"> <label class="col-sm-3 control-label" for="amount">Amount</label> <div clas
<div class="form-group">
<label class="col-sm-3 control-label" for="amount">Amount</label>
<div class="col-sm-9">
<input type="number" class="form-control" name="amount"
id="amount" placeholder="Amount">
</div>
</div>
<div class="form-group">
<div class="col-sm-2">
<button type="submit" class="btn btn-success" id="pay-now" name="pay-
now">Pay Now</button>
</div>
</div>
数量
现在付款
以下是使用tcpdf的php代码:
if(isset($_POST["pdf"]))
{
require_once('tcpdf/tcpdf.php');
$obj_pdf = new TCPDF('P', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8',
false);
$obj_pdf->SetCreator(PDF_CREATOR);
$obj_pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '',
PDF_FONT_SIZE_MAIN));
$obj_pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '',
PDF_FONT_SIZE_DATA));
$obj_pdf->SetDefaultMonospacedFont('helvetica');
$obj_pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$obj_pdf->SetMargins(PDF_MARGIN_LEFT, '4', PDF_MARGIN_RIGHT);
$obj_pdf->setPrintHeader(false);
$obj_pdf->setPrintFooter(false);
$obj_pdf->SetAutoPageBreak(TRUE, 10);
$obj_pdf->SetFont('helvetica', '', 12);
$obj_pdf->AddPage();
$sql = "SELECT * FROM donors WHERE user_name='$username'";
$result = mysqli_query($conn, $sql);
$html = '';
$html .= '
<!doctype html>
<html lang="en">
<head>
<style>
.text-center{
text-align: center;
}
.img-fluid{
width: 200px;
height: 41px;
}
.title{
text-decoration: underline;
}
.text-left{
text-align: left;
}
</style>
</head>
<body>
<div >
<div class="text-center">
<div >
<img src="img/logo.png" class="img-fluid">
</div>
<div class="title">
<h1>Donation Report</h1>
</div>
<div >
<h3 >';
$html .= "Date : " . date("m-d-Y");
$html .= '</h3>
</div>
<div class="text-left">
<h4>Hello ';
$html .= $_SESSION['u_user_name'];
$html .= ',</h4>
<p>Thanks a lot for donating and supporting us. Please find your
details below for tax filing:</p>
</div>
<div>
<table border="1" cellspacing="0" cellpadding="5" id="box">
<tr>
<td>Date</td>
<td>Amount</td>
</tr><tr><td>';
$html .= date("m-d-Y");
$html .= '</td><td>';
while($row = mysqli_fetch_assoc($result)){
$html .= $row["total_donation_amount"];
}
$html .= '</td></tr></table>
</div>
<div class=" text-left">
<h4>Thanks and Regards,</h4>
<h4>Detroit Pheonix Center</h4>
<h4>Detroit, Mi</h4>
</div>
</div>
</div>
</body>
</html>';
$obj_pdf->writeHTML($html);
$obj_pdf->Output('donor_report.pdf', 'D');}
if(isset($\u POST[“pdf”]))
{
一次需要_('tcpdf/tcpdf.php');
$obj_pdf=新的TCPDF('P',pdf_单位,pdf_页面_格式,真,'UTF-8',
假);
$obj_pdf->SetCreator(pdf_CREATOR);
$obj_pdf->setHeaderFont(数组(pdf_FONT_NAME_MAIN.),
PDF(字体大小),;
$obj_pdf->setFooterFont(数组(pdf_FONT_NAME_DATA)”,
PDF(字体大小数据);
$obj_pdf->SetDefaultMonospacedFont('helvetica');
$obj_pdf->SetFooterMargin(pdf_MARGIN_FOOTER);
$obj_pdf->SetMargins(pdf_MARGIN_左,'4',pdf_MARGIN_右);
$obj_pdf->setPrintHeader(假);
$obj_pdf->setPrintFooter(false);
$obj_pdf->SetAutoPageBreak(TRUE,10);
$obj_pdf->SetFont('helvetica','',12);
$obj_pdf->AddPage();
$sql=“从捐赠者中选择*,其中用户名为“$username”;
$result=mysqli\u查询($conn,$sql);
$html='';
$html.='
.文本中心{
文本对齐:居中;
}
.img液{
宽度:200px;
高度:41px;
}
.头衔{
文字装饰:下划线;
}
.左文本{
文本对齐:左对齐;
}
捐赠报告
';
$html.=“日期:”.Date(“m-d-Y”);
$html.='
你好;
$html.=$\u会话['u\u用户名'];
$html.=',
非常感谢您的捐赠和支持。请找到您的
税务申报详情如下:
日期
数量
';
$html.=日期(“m-d-Y”);
$html.='';
while($row=mysqli\u fetch\u assoc($result)){
$html.=$row[“捐赠总额”];
}
$html.='
感谢和问候,
底特律凤凰中心
密歇根州底特律
';
$obj_pdf->writeHTML($html);
$obj_pdf->Output('donator_report.pdf','D');}
在这里,当我提交表单时,我希望付款日期和金额应显示在pdf的表格行中,每次我这样做时,该行应附加到pdf中。pdf是使用pdf按钮打印的,这是我在这里没有提到的其他代码。代码?您正在处理的代码在哪里。通过编辑将其添加到您的问题中您不需要将其附加到文件中,而是需要从数据库中检索旧数据和新数据并重写文件(用同名的新更新版本替换它)嗨,我已更新了我的代码。请帮帮我。@Amr Berag我该怎么做??你能解释清楚吗。还有一件事,每次提交表单时,我都会覆盖db中的金额值。是否有替代解决方案而不是覆盖。@AbhinayRaj是的,您添加它而不是覆盖。也许您需要引用第一个表的第二个表