php表单处理多个复选框

wwtsj6pe  于 2021-06-20  发布在  Mysql
关注(0)|答案(0)|浏览(272)

所以我有一张满是数据的表格。我有一个页面,我列出了所有的内容,可以通过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中对null的成员函数output()调用。php:80 stack trace:#0{main}在第80行的/homepages/38/d735513801/htdocs/future/pdfgen/labelex.php中抛出

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题