Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/254.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/78.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 打印HTML生成的身份证_Php_Html - Fatal编程技术网

Php 打印HTML生成的身份证

Php 打印HTML生成的身份证,php,html,Php,Html,我已经用HTML和PHP创建了一张身份证,我想在点击按钮时打印它。但我不知道下一步该做什么 目前我只有以下代码。单击generate_idcard按钮时,会打开打印对话框进行打印,接下来该怎么办 if(isset($_POST['generate_idcard'])){ $idcard = '<div class="idholder"> <div class="photobox"><img src="students/'.$f

我已经用HTML和PHP创建了一张身份证,我想在点击按钮时打印它。但我不知道下一步该做什么

目前我只有以下代码。单击
generate_idcard
按钮时,会打开打印对话框进行打印,接下来该怎么办

if(isset($_POST['generate_idcard'])){
    $idcard = '<div class="idholder">
                <div class="photobox"><img src="students/'.$f['st_photo'].'" width="102" height="105"></div>
                <div class="idtxt idtxt1">'.$f['st_dob'].'</div>
                <div class="idtxt idtxt2">'.$f['st_blood'].'</div>
                <div class="idtxt idtxt3">'.$f['st_phone'].'</div>
                <div class="idtxt idtxt4">'.$f['st_admtype'].'</div>
                <div class="idtxt idtxt5">'.$f['st_name'].'</div>
                <img src="images/idcard.png" width="300" height="390">
               </div>';

}
if(isset($\u POST['generate\u idcard'])){
$idcard=
“.$f['st_dob']”
“.$f['st_blood]”
“.$f['st_phone']”
“.$f['st_admtype']”
“.$f['st_name']”
';
}
目前,此代码在回显时可以完美地显示身份证。我现在只需要把它打印出来。请帮助我写下什么代码来打印它。

你想要它吗

A4纸张大小的CSS代码



@media print {
    body{
        width: 21cm;
        height: 29.7cm;
        margin: 30mm 45mm 30mm 45mm; 

   } 
}

Php和html代码



<?php if(isset($_POST['generate_idcard'])) :?>
               <div class="idholder">
                <div class="photobox"><img src="students/'<?=$f['st_photo']?>" width="102" height="105"></div>
                <div class="idtxt idtxt1"><?=$f['st_dob']?></div>
                <div class="idtxt idtxt2"><?=$f['st_blood']?></div>
                <div class="idtxt idtxt3"><?=f['st_phone']?></div>
                <div class="idtxt idtxt4"><?=$f['st_admtype']?></div>
                <div class="idtxt idtxt5"><?=f['st_name']?></div>
                <img src="images/idcard.png" width="300" height="390">
               </div>

            <button onclick="window.print()>print</button>

<?php endif; ?>


“width=“102”height=“105”>
你想要它吗

A4纸张大小的CSS代码



@media print {
    body{
        width: 21cm;
        height: 29.7cm;
        margin: 30mm 45mm 30mm 45mm; 

   } 
}

Php和html代码



<?php if(isset($_POST['generate_idcard'])) :?>
               <div class="idholder">
                <div class="photobox"><img src="students/'<?=$f['st_photo']?>" width="102" height="105"></div>
                <div class="idtxt idtxt1"><?=$f['st_dob']?></div>
                <div class="idtxt idtxt2"><?=$f['st_blood']?></div>
                <div class="idtxt idtxt3"><?=f['st_phone']?></div>
                <div class="idtxt idtxt4"><?=$f['st_admtype']?></div>
                <div class="idtxt idtxt5"><?=f['st_name']?></div>
                <img src="images/idcard.png" width="300" height="390">
               </div>

            <button onclick="window.print()>print</button>

<?php endif; ?>


“width=“102”height=“105”>

我说我想把它打印出来。。。把它印在纸上。。A4纸。。使用打印机?你所做的只是改变我写代码的方式。。让我告诉你你所做的是在PHP4中使用的一种obsole方式。我理解如何更清楚地打印这段代码,很抱歉你想在printer@media print上使用它{body{width:21cm;height:29.7cm;margin:30mm 45mm 30mm 45mm;}我不知道如何使用你的代码。你能在我上面的代码上实现吗?我说我想打印它。。。把它印在纸上。。A4纸。。使用打印机?你所做的只是改变我写代码的方式。。让我告诉你你所做的是在PHP4中使用的一种obsole方式。我理解如何更清楚地打印这段代码,很抱歉你想在printer@media print上使用它{body{width:21cm;height:29.7cm;margin:30mm 45mm 30mm 45mm;}我不知道如何使用你的代码。你能在我上面的代码上实现吗?