Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP/MySQL打印重复标签_Php_Mysql_Pdf_Fpdf_Labels - Fatal编程技术网

PHP/MySQL打印重复标签

PHP/MySQL打印重复标签,php,mysql,pdf,fpdf,labels,Php,Mysql,Pdf,Fpdf,Labels,我使用FPDF的一个插件,使用PHP/MySQL()打印标签。我希望能够让用户选择要打印多少标签。例如,如果查询输出10条记录,并且用户希望为每条记录打印3个标签,那么它将在一组中打印所有记录。1,1,1,2,2,2,3,3…等。有什么想法吗 <?php require_once('auth.php'); require_once('../config.php'); require_once('../co

我使用FPDF的一个插件,使用PHP/MySQL()打印标签。我希望能够让用户选择要打印多少标签。例如,如果查询输出10条记录,并且用户希望为每条记录打印3个标签,那么它将在一组中打印所有记录。1,1,1,2,2,2,3,3…等。有什么想法吗

     <?php
            require_once('auth.php'); 
            require_once('../config.php'); 
            require_once('../connect.php');     

            require('pdf/PDF_Label.php');

            $sql="SELECT $tbl_members.lastname, $tbl_members.firstname, 
    $tbl_members.username, $tbl_items.username, $tbl_items.itemname 
FROM $tbl_members, $tbl_items
WHERE $tbl_members.username = $tbl_items.username";
            $result=mysql_query($sql);

            if(mysql_num_rows($result) == 0){
            echo "Your search criteria does not return any results, please try again.";
            exit();
            }

            $pdf = new PDF_Label("5160");

            $pdf->AddPage();

            // Print labels
            while($rows=mysql_fetch_array($result)){
                $name = $rows['lastname'].', '.$rows['firstname';
                $item= $rows['itemname'];

                $text = sprintf("  * %s *\n  %s\n", $name, $item);
                $pdf->Add_Label($text);
            }

            $pdf->Output('labels.pdf', 'D');
            ?>

假设像
$copies
这样的变量是他们想要复制多少份的整数,我将进行以下修改:

// Print labels
while( $row = mysql_fetch_array( $result ) ){
  // Run Once for Each Result
    $name = $row['lastname'].', '.$row['firstname'];
    $item = $row['itemname'];
    $text = sprintf("  * %s *\n  %s\n", $name, $item);
    if( isset( $copies ) ) {
      // The Copies Variable exists
        for( $i=0 ; $i<$copies ; $i++ ) {
          // Run X times - Once for each Copy
            $pdf->Add_Label($text);
        }
    } else {
      // The Copies Variable does not exist - Assume 1 Copy
        $pdf->Add_Label($text);
    }
}
//打印标签
while($row=mysql\u fetch\u数组($result)){
//为每个结果运行一次
$name=$row['lastname'.','.$row['firstname'];
$item=$row['itemname'];
$text=sprintf(“*%s*\n%s\n”,$name,$item);
如果(isset(份)){
//Copies变量存在
对于($i=0;$iAdd_标签($text);
}
}否则{
//Copies变量不存在-假定为1 Copy
$pdf->添加标签($text);
}
}
这应该提供所需的功能