Php 打印时插入HTML表格的换行符
我有一个PHP脚本,它运行for循环,echo输出HTML表行和数据。但是,当我进行打印/打印预览时,会随机出现在表格行中插入换行符的情况,我不知道为什么。它似乎完美地呈现了浏览器中的所有内容。。。请看下面第7行打印预览的屏幕截图。我尝试将高度指定为0 以下是我在PHP中使用的代码:Php 打印时插入HTML表格的换行符,php,html-table,Php,Html Table,我有一个PHP脚本,它运行for循环,echo输出HTML表行和数据。但是,当我进行打印/打印预览时,会随机出现在表格行中插入换行符的情况,我不知道为什么。它似乎完美地呈现了浏览器中的所有内容。。。请看下面第7行打印预览的屏幕截图。我尝试将高度指定为0 以下是我在PHP中使用的代码: $counter = 1; $tCounter = 1; $pCounter = 1; $tc=9; for($i=0; $i<count($spiceType); $i++){ $resu
$counter = 1;
$tCounter = 1;
$pCounter = 1;
$tc=9;
for($i=0; $i<count($spiceType); $i++){
$result = mysql_query("SELECT * FROM `spices` WHERE `type`='$spiceType[$i]' ORDER BY ID")or die(mysql_error());
$spiceCat = $spiceType[$i];
echo '<tr>
<td colspan="6" ><p class="cat" >'.$spiceCat.'</p></td>
<tr>';
while($r=mysql_fetch_array($result)){
$pname = $r[productName];
$qty = $r[qty];
$price = $r[price];
$upcNum = $r[upcNumber];
$imageName = substr($upcNum, 0, -1);
$imageName = "0".$imageName.".jpg";
echo'
<tr height="0">
<td width="25"><p class="counter">'.$counter.'</counter></td>
<td width="200"><p class="productName"><a href="edit.php?upc='.$upcNum.'&pn='.$pname.'" class="links" name="'.$pname.'">'.$pname.'</a></p></td>
<td width="50"><p class="qty">'.$qty.'</p></td>
<td width="100"><p class="price">'.$price.'</p></td>
<td width="25"><p class="upc">'.$upcNum.'</p></td>
<td width="50" align="center"><img src="upcjpeg/'.$imageName.'" style="width: 85%; height: inherit; vertical-align:text-top"></td>
<tr>';
if($tCounter==$tc){
$tCounter=1;
$tc=11;
echo'
</table>
<p align="right">Page: '.$pCounter.'
<div class="page-break"></div>
<table width="1024" class="sample">
<tr border="0" cellpadding="0">
<th width="25"><h2><p align="center">#</p></h2></th>
<th width="200"><h2><p align="center">Product Name</p></h2></th>
<th width="50"><h2><p align="center">Qty</p><h2></th>
<th width="100"><h2><p align="center">Price</p><h2></th>
<th width="25"><h2><p align="center">UPC No.</p><h2></th>
<th width="50"><h2><p align="center">Barcode</p><h2></th>
</tr>
<tr>
<td colspan="6" bgcolor=#E0E0E0><p class="catCont">'.$spiceCat.'(cont.)</p></td>
<tr>';
$pCounter++;
} else {
$tCounter++;
}
$counter++;
}
}
你能发布生成表格的代码吗?看一张图片是不可能解决这个问题的。如果没有一些代码,很难看到问题。顺便说一句:我刚刚注意到结束TR标记没有反斜杠…我已经解决了这个问题,它仍然做同样的事情。一旦它在特定行生成,源代码中有什么奇怪的地方吗?此外,如果在表中的其他位置插入该特定行,问题是否仍然存在?在第4行?@crimsonfox-不,源代码看起来也不错。。。彼此相同。在浏览器中查看是可以的,只有当我打印时才添加空白。它在所有其他页面的同一行中重复,但不是在顶部添加空白,而是添加到底部。