如何解决在标签打印机中打印HTML表
此布局填充了来自搜索结果的数据 Web结果WooCommerce以CSV下载
使用PHP,我可以从CSV中提取每一行,并为每个订单创建一个标签。
我尝试使用 Ctrl + P 打印,但这不起作用
如何直接打印到打印机或为每个表格创建图像并自动打印它们?
这是我的代码
订购CSV数据(PHP)
$orders = array();
$neworders=array();
$h = fopen("orders.csv","r");
$header = fgetcsv($h);
while (($data = fgetcsv($h,1000,",")) !== FALSE){
$orders[] = array_combine($header,$data);
}
fclose($h);
$z=0;
$flag=false;
for($i=0;$i<sizeof($orders);$i++){
if(sizeof($neworders)>0){
for($x=0;$x<sizeof($neworders);$x++){
if($neworders[$x]['Order ID']==$orders[$i]['Order ID']){
$neworders[$x]['Product ID'][]=$orders[$i]['Product ID'];
$neworders[$x]['Product SKU'][]=$orders[$i]['Product SKU'];
$neworders[$x]['Product Name'][]=$orders[$i]['Product Name'];
$neworders[$x]['Quantity of items purchased'][]=$orders[$i]['Quantity of items purchased'];
$neworders[$x]['All Line Metadata'][]=$orders[$i]['All Line Metadata'];
$flag=true;
break;
}
}
if($flag==false){
$neworders[$z]['Order ID']=$orders[$i]['Order ID'];
$neworders[$z]['Order Date']=$orders[$i]['Order Date'];
$neworders[$z]['Order Status']=$orders[$i]['Order Status'];
$neworders[$z]['Shipping RUT']=$orders[$i]['Shipping RUT'];
$neworders[$z]['Shipping First Name']=$orders[$i]['Shipping First Name'];
$neworders[$z]['Shipping Last Name']=$orders[$i]['Shipping Last Name'];
$neworders[$z]['Shipping Method Title']=$orders[$i]['Shipping Method Title'];
$neworders[$z]['Shipping Country']=$orders[$i]['Shipping Country'];
$neworders[$z]['Shipping State']=$orders[$i]['Shipping State'];
$neworders[$z]['Shipping City']=$orders[$i]['Shipping City'];
$neworders[$z]['Shipping Address Line 1']=$orders[$i]['Shipping Address Line 1'];
$neworders[$z]['Shipping Address Line 2']=$orders[$i]['Shipping Address Line 2'];
$neworders[$z]['Shipping Phone Number']=$orders[$i]['Shipping Phone Number'];
$neworders[$z]['Customer Note']=$orders[$i]['Customer Note'];
$neworders[$z]['Product ID'][]=$orders[$i]['Product ID'];
$neworders[$z]['Product SKU'][]=$orders[$i]['Product SKU'];
$neworders[$z]['Product Name'][]=$orders[$i]['Product Name'];
$neworders[$z]['Quantity of items purchased'][]=$orders[$i]['Quantity of items purchased'];
$neworders[$z]['All Line Metadata'][]=$orders[$i]['All Line Metadata'];
$z++;
}
}else{
$neworders[$z]['Order ID']=$orders[$i]['Order ID'];
$neworders[$z]['Order Date']=$orders[$i]['Order Date'];
$neworders[$z]['Order Status']=$orders[$i]['Order Status'];
$neworders[$z]['Shipping RUT']=$orders[$i]['Shipping RUT'];
$neworders[$z]['Shipping First Name']=$orders[$i]['Shipping First Name'];
$neworders[$z]['Shipping Last Name']=$orders[$i]['Shipping Last Name'];
$neworders[$z]['Shipping Method Title']=$orders[$i]['Shipping Method Title'];
$neworders[$z]['Shipping Country']=$orders[$i]['Shipping Country'];
$neworders[$z]['Shipping State']=$orders[$i]['Shipping State'];
$neworders[$z]['Shipping City']=$orders[$i]['Shipping City'];
$neworders[$z]['Shipping Address Line 1']=$orders[$i]['Shipping Address Line 1'];
$neworders[$z]['Shipping Address Line 2']=$orders[$i]['Shipping Address Line 2'];
$neworders[$z]['Shipping Phone Number']=$orders[$i]['Shipping Phone Number'];
$neworders[$z]['Customer Note']=$orders[$i]['Customer Note'];
$neworders[$z]['Product ID'][]=$orders[$i]['Product ID'];
$neworders[$z]['Product SKU'][]=$orders[$i]['Product SKU'];
$neworders[$z]['Product Name'][]=$orders[$i]['Product Name'];
$neworders[$z]['Quantity of items purchased'][]=$orders[$i]['Quantity of items purchased'];
$neworders[$z]['All Line Metadata'][]=$orders[$i]['All Line Metadata'];
$z++;
}
}
<!DOCTYPE html>
<html>
<head>
<style>
table {
font-family: arial,sans-serif;
border-collapse: collapse;
max-width:58mm;
max-heigth:90mm;
width:58mm;
heigth:90mm;
overflow:auto;
display:block;
}
td,th {
border: 1px solid #dddddd;
text-align: left;
padding: 3px;
font-size:12px;
}
</style>
</head>
<body>
<?PHP
for($i=0;$i<sizeof($neworders);$i++){
?>
<table id="myTable">
<tr>
<th colspan="2"><img width="100%" src="logo.png"/></th>
</tr>
<tr >
<td>RUT:</td>
<td><?PHP echo $neworders[$i]['Shipping RUT'];?></td>
</tr>
<tr>
<td colspan="2" style="font-size:12px"><?PHP echo ucfirst($neworders[$i]['Shipping First Name'])." ".ucfirst($neworders[$i]['Shipping Last Name']);?></td>
</tr>
<tr>
<td colspan="2" ><?PHP echo regiones($neworders[$i]['Shipping State'])."/".$neworders[$i]['Shipping City'];?></td>
</tr>
<tr>
<td colspan="2">Dirección:</td>
</tr>
<tr>
<td colspan="2">
<?PHP
echo $neworders[$i]['Shipping Address Line 1'];
if(strlen($neworders[$i]['Shipping Address Line 2'])>0){
echo " - ".$neworders[$i]['Shipping Address Line 2'];
}
if(strlen($neworders[$i]['Customer Note'])>0){
echo " (".$neworders[$i]['Customer Note'].")";
}
?></td>
</tr>
<tr>
<td>Teléfono:</td>
<td><?PHP echo $neworders[$i]['Shipping Phone Number'];?></td>
</tr>
<tr>
<td colspan="2" style="font-size:10px">
<?PHP
for($x=0;$x<sizeof($neworders[$i]['Product ID']);$x++){
echo "(".$neworders[$i]['Quantity of items purchased'][$x].") ";
echo $neworders[$i]['Product ID'][$x]."|";
echo $neworders[$i]['Product Name'][$x]."(";
echo explodepolera($neworders[$i]['All Line Metadata'][$x]).")</br>";
}
?>
</td>
</tr>
</table>
<br/>
<?PHP
}
?>
</body>
我尝试在此行之后为($ I = 0; $ I
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。