微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

我如何通过选定的检查值以 pdf 格式打印多条记录

如何解决我如何通过选定的检查值以 pdf 格式打印多条记录

这是我的代码,因为我想打印多个 pdf 文件,但问题是我需要使用复选框获取值,例如在导入文件显示记录,然后以 pdf 格式打印单个记录,但我想要要在 1 个带有差异页面的 pdf 文件中打印整个记录,例如如果我选择 4 个复选框,它将在 pdf 中生成 4 个页面,请查看我的代码

- name: setup-java
  uses: actions/setup-java@v2-preview
  with:
    distribution: 'adopt'
    java-version: '11'

下面是 gen_pdf.PHP代码

    <?PHP

    $connect = MysqLi_connect("localhost","root","","excel");
    $output = '';
    if(isset($_POST["import"]))
    {
    $extension = end(explode(".",$_FILES["excel"]["name"])); // For getting Extension of selected file

    $allowed_extension = array("xls","xlsx","csv"); //allowed extension
    if(in_array($extension,$allowed_extension)) //check selected file extension is present in allowed extension array
    {
    $file = $_FILES["excel"]["tmp_name"]; // getting temporary source of excel file
    include("PHPExcel/IOFactory.PHP"); // Add PHPExcel Library in this code
    $objPHPExcel = PHPExcel_IOFactory::load($file); // create object of PHPExcel library by using load() method and in load method define path of selected file

    $output .= "<label class='text-success'>Data Inserted</label><br /><table class='table table-bordered'>
    <thead class='thead-dark'>
    <tr>
        <th>Client Name</th>
        <th>Client Email</th>
        <th>Client PHone:</th>
        <th>Action:</th>
        <th>Selection:</th>
    </tr>
    </thead>
    ";
    foreach ($objPHPExcel->getWorksheetIterator() as $worksheet)
    {
    $highestRow = $worksheet->getHighestRow();
    for($row=0; $row<=$highestRow; $row++)
    {
        
        $output .= "<tr>";
        $name = MysqLi_real_escape_string($connect,$worksheet->getCellByColumnAndRow(0,$row)->getValue());
        $email = MysqLi_real_escape_string($connect,$worksheet->getCellByColumnAndRow(1,$row)->getValue());
        $phone = MysqLi_real_escape_string($connect,$worksheet->getCellByColumnAndRow(2,$row)->getValue());
        if ($name!='') {
            $sql = "INSERT INTO excel_data(names,mails,phone) VALUES('".$name."','".$email."','".$phone."')";
            MysqLi_query($connect,$sql);
        }
        $datafecth2=MysqLi_query($connect,"SELECT * FROM excel_data");
        while ($dd=MysqLi_fetch_array($datafecth2)) {
            $recordid = $dd['id'];
        }

        $output .= '<td>'.$name.'</td>';
        $output .= '<td>'.$email.'</td>';
        $output .= '<td>'.$phone.'</td>';

            $output .= "<td> <form action='gen_pdf.PHP?docid=$recordid' method='post'>
            <button type='submit' name='btn_pdf' class='btn btn-success'>Gen PDF</button>
            </form>
            </td>";
        $output .= "<td><input type='checkBox' class='form-check-input' name='delete[]' value='$recordid' ></td>";
        
        
        $output .= '</tr>';
    }
    } 
    $output .= "<form action='gen_pdf2.PHP?docid=delete[]' method='post'>
    <button type='submit' name='btn_pdf' class='btn btn-success'>Gen PDF</button>
    </form>";
    $output .= '</table>';
    }
    else
    {
    $output = '<label class="text-danger">Invalid File</label>'; //if non excel file then
    }
    }
    ?>

    <html>
    <head>
    <title>Import Excel to MysqL using PHPExcel in PHP</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
    <style>
    body
    {
    margin:0;
    padding:0;
    background-color:#f1f1f1;
    }
    .Box
    {
    width:700px;
    border:1px solid #ccc;
    background-color:#fff;
    border-radius:5px;
    margin-top:100px;
    }
    
    </style>
    </head>
    <body>
    <div class="container Box">
    <h3 align="center">Data Insertion Practice</h3><br />
    <form method="post" enctype="multipart/form-data">
        <label>Select Excel File</label>
        <input type="file" name="excel" />
        <br />
        <input type="submit" name="import" class="btn btn-info" value="Import" />
    </form>
    <br />
    <br />

    <?PHP
    echo $output;
    echo $output1;
    ?>
    </div>
    <br>
    <br>
    <br>
    </body>
    </html>

解决方法

您发布的代码对表格的每一行使用单独的 glPixelStorei(GL_PACK_ALIGNMENT,4); glReadPixels(x,y,width,height,GL_RGBA,GL_UNSIGNED_BYTE,data); 按钮。这只会发送一行进行处理。

要选择多行,您需要在带有单个 submit 按钮的单个表单中使用复选框。使用数组语法设置复选框的名称(例如 name='cbox[]'),并将复选框的值设置为提交表单时要处理的行的标识。

提交表单后,复选框的值将传递给您的 PHP 脚本,并可作为 submit 中的数组访问。未选中的框将被忽略,因此您可以简单地处理 ID 列表。

下面的代码说明了这个过程

$_POST

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?