使用 tcpdf 创建 pdf 时可以执行 php 代码吗?

发布于 2024-11-28 07:03:38 字数 2042 浏览 1 评论 0原文

我正在开发一个模块,其中我必须从 php 页面制作 pdf。我正在使用 tcpdf ,但我面临一个问题,该文件包含一些 mysql 查询和 php 编码,这些编码不是由 pdf 页面执行的。

$prn_no = $_POST['prn_no'];

$current_sem = $_POST['current_sem'];

$qr_fetch_sem_res_id = mysql_query("SELECT * FROM table1 WHERE ((prn='$prn_no') AND (semisterName='$current_sem'))")or die(mysql_error());

    $qr_fetch_sem_result_ans = mysql_fetch_array($qr_fetch_sem_res_id);

  <tr>
    <td colspan="11" align="left" valign="middle">Programme Name:&nbsp;<?php echo $qr_fetch_sem_result_ans['programme_name'];?></td>
  </tr>
  <tr>
    <td colspan="11" align="center" valign="middle"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="27%">Seat No.: <?php echo $qr_fetch_sem_result_ans['seatNo'];?></td>
        <td width="3%">&nbsp;</td>
        <td width="22%">PR No. : <?php echo $qr_fetch_sem_result_ans['prn'];?></td>
        <td width="2%">&nbsp;</td>
        <td width="17%">Semester : <?php echo $qr_fetch_sem_result_ans['semisterName'];?></td>
        <td width="1%">&nbsp;</td>
        <td width="25%">Month / Year Of Exam : <?php echo $qr_fetch_sem_result_ans['month_year_of_exam'];?> </td>
        <td width="3%">&nbsp;</td>
      </tr>
      <tr>
        <td colspan="3">Name: <?php echo $qr_fetch_sem_result_ans['student_name'];?></td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td colspan="7">College / Institute: <?php echo $qr_fetch_sem_result_ans['institute_name'];?></td>
        <td>&nbsp;</td>
      </tr>
    </table></td>
  </tr>

I m working on module in which i have to make pdf from php page. I m Using tcpdf for that but m facing one problem that file contain some mysql queries and php coding which is not executed by pdf page.

$prn_no = $_POST['prn_no'];

$current_sem = $_POST['current_sem'];

$qr_fetch_sem_res_id = mysql_query("SELECT * FROM table1 WHERE ((prn='$prn_no') AND (semisterName='$current_sem'))")or die(mysql_error());

    $qr_fetch_sem_result_ans = mysql_fetch_array($qr_fetch_sem_res_id);

  <tr>
    <td colspan="11" align="left" valign="middle">Programme Name: <?php echo $qr_fetch_sem_result_ans['programme_name'];?></td>
  </tr>
  <tr>
    <td colspan="11" align="center" valign="middle"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="27%">Seat No.: <?php echo $qr_fetch_sem_result_ans['seatNo'];?></td>
        <td width="3%"> </td>
        <td width="22%">PR No. : <?php echo $qr_fetch_sem_result_ans['prn'];?></td>
        <td width="2%"> </td>
        <td width="17%">Semester : <?php echo $qr_fetch_sem_result_ans['semisterName'];?></td>
        <td width="1%"> </td>
        <td width="25%">Month / Year Of Exam : <?php echo $qr_fetch_sem_result_ans['month_year_of_exam'];?> </td>
        <td width="3%"> </td>
      </tr>
      <tr>
        <td colspan="3">Name: <?php echo $qr_fetch_sem_result_ans['student_name'];?></td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
        <td> </td>
      </tr>
      <tr>
        <td colspan="7">College / Institute: <?php echo $qr_fetch_sem_result_ans['institute_name'];?></td>
        <td> </td>
      </tr>
    </table></td>
  </tr>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

守不住的情 2024-12-05 07:03:38

我将在这里冒险建议你先运行你的查询,然后构建你的 pdf 文件。如果您在构建 pdf 后运行查询,那么它当然无法访问您的数据。如果这没有帮助,那么我一定不明白你在问什么。

I'm going to go out on a limb here and suggest that you run your queries fist and then build your pdf file. If you run the queries after you build the pdf then of course it will not have access to your data. If that doesn't help then I must not understand what you're asking.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文