打印时将换行符插入HTML表格中

时间:2011-07-17 22:39:42

标签: php html-table

我有一个PHP脚本,它运行for循环并回显出HTML表行和数据。但是当我进行打印/打印预览并且我不知道为什么时,我会随机出现在表行中插入换行符的情况。它似乎可以完美地呈现浏览器中的所有内容...请查看下面第7行打印预览的屏幕截图。我尝试将高度指定为0

enter image description here

这是我在PHP中使用的代码:

$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++;

    }
}

0 个答案:

没有答案