PHP表单处理多个复选框

时间:2018-08-28 12:43:12

标签: php html mysql forms

所以我有一个充满数据的表。我有一个页面,其中我通过while循环列出了所有能够列出的内容。然后,用户可以单击记录上的按钮,它将使用其所拥有的数据生成地址标签,并且所生成的标签以PDF格式完成。这样所有文件都可以正常工作。但是我想知道是否可以将每个记录的HTML复选框替换为类似的按钮

<input type="checkbox" name="<?php echo $recordTitle; ?>" />
<input type="hidden" name="<?php echo $recordID"; ?>" />

因此,这将使人们可以选择多个记录,然后单击一个按钮,它将带走所有这些记录并生成所需数量的标签。如果有可能,我将如何处理所有这些,因为我需要以某种方式遍历用户选择的所有记录。

<?php
$eventSearch = $_POST['eventSearch'];
//Include Database connection
include '../includes/dbConnect.php';

foreach ($arr as &$value) {
$id = $value; 

//Query Database for all customer info
$sql = "SELECT * FROM customerInterest WHERE `id` = '$value'";
$result = mysqli_query($dbLink, $sql);
$row = mysqli_fetch_assoc($result);


//require the document that creates the PDF
require('PDF_Label.php');

//Create a new PDF
$pdf = new PDF_Label('L7163');
$pdf->AddPage();

    //assign the customer information to a variable
    $sal =  $row["salutation"];
    $fn = $row["firstName"];
    $ln = $row["lastName"];
    $add1 = $row["contactAddress1"];
    $add2 = $row["contactAddress2"];
    $city = $row["contactAddressCity"];
    $state = $row["contactAddressState"];
    $post = $row["contactAddressPostcode"];
    $country = $row["contactAddressCountry"];
    if ($sal == "N/A") {
      $sal = "";
    }
    if ($fn == "N/A") {
      $fn = "";
    }
    if ($ln == "N/A") {
      $ln = "";
    }
    if ($add1 == "N/A") {
      $add1 = "";
    }
    if ($add2 == "N/A") {
      $add2 = "";
    }
    if ($city == "N/A") {
      $city = "";
    }
    if ($state == "N/A") {
      $state = "";
    }
    if ($post == "N/A") {
      $post = "";
    }
    if ($country == "N/A") {
      $country = " ";
    }
    $add1 = $add1." ".$add2;

    $post = str_replace(' ', '', $post);
    $post = strtoupper($post);

    $post = substr_replace($post, " ", 4, 0);



    // Standard format

    //create new page


        // Print labels
        $text = sprintf("%s\n%s\n%s\n%s %s",$sal." ".$fn." ".$ln, $add1, $city, $state, $post,$country);
        $pdf->Add_Label($text);


}
 //Output all the info
 $pdf->Output();



?>

因此,上面包含了我现在尝试过的代码。我已将数据发布到PDf生成页面(所有代码均来自此页面),并且不断收到错误消息(请参见下文),我无法弄清为什么:/

致命错误:未捕获的错误:在/homepages/38/d735513801/htdocs/future/pdfGen/labelEX.php:80中对null的成员函数Output()进行调用:堆栈堆栈跟踪:#0 {main}抛出于/ homepages /38/d735513801/htdocs/future/pdfGen/labelEX.php,第80行

0 个答案:

没有答案