I have a PHP script that runs a for loop and echo's out HTML Table rows and data. However I get random occurrences where a line break is inserted into a table row when I do print/print preview and I don't know why. It seems to render everything in the browser perfectly though... Take a look at the screenshot of the print preview below for row 7. I tried specifying height to 0
Here's the code I'm using in 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>开发者_JS百科</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++;
}
}
精彩评论