0
我有一個打印一堆收據的PHP/HTML頁面。實際打印時,我試圖在每個打印後分頁。我已經嘗試過幾種風格和課程代碼,但是我已經能夠做的最好的事情是在第一次之後將其破解,但它從不重複。 IOW我希望它在每次打印代碼中引用的表格後分頁。僅分頁一次
enter code here
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head>
<style type="text/css">
@media all {
.page-break { display: none; }
}
@media print {
.page-break { display: block; page-break-before: always; }
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>North Atlanta Riding Club</title>
<link href="../styles.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style45 {
color: #FF0000;
font-weight: bold;
font-style: italic;
}
-->
</style>
</head>
<body>
<?php
do{
//THIS SEES IF THE LOGGED IN MEMBER HAS CONFIRMED CLOTHING
$colname_confirmed = "1";
if (isset($row_roster['key1'])) {
$colname_confirmed = (get_magic_quotes_gpc()) ? $row_roster['key1'] : addslashes($row_roster['key1']);
}
mysql_select_db($database_connection1, $connection1);
$query_confirmed = sprintf("SELECT * FROM clothingorder WHERE who = %s AND confirmed = 'Y' ORDER BY key1 ASC", $colname_confirmed);
$confirmed = mysql_query($query_confirmed, $connection1) or die(mysql_error());
$row_confirmed = mysql_fetch_assoc($confirmed);
$totalRows_confirmed = mysql_num_rows($confirmed);
if($totalRows_confirmed<>0){?>
<table width="990" border="0" align="left" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="990" height="31" valign="top"><!--DWLayoutEmptyCell--> </td>
</tr>
<tr>
<td height="83" valign="top">
<table border="1" align="left" cellpadding="2" cellspacing="0" bordercolor="#000000">
<tr bgcolor="#FFFFFF" class="style5">
<td colspan="9"><p>Member- <strong><?php echo $row_roster['fname']." ".$row_roster['lname']; ?><br>
</strong>Telephone- <strong><?php echo $row_roster['tel']; ?></strong> Email- <strong><?php echo $row_roster['email']; ?></strong><br>
Address- <br>
<strong>
<?php if($row_roster['add1']<>''){echo $row_roster['add1']."<br>";} ?>
</strong>
<strong>
<?php if($row_roster['add2']<>''){echo $row_roster['add2']."<br>";} ?>
</strong>
<strong>
<?php if($row_roster['city']<>''){echo $row_roster['city'].", ";} ?>
</strong>
<strong>
<?php if($row_roster['state']<>''){echo $row_roster['state']." ";} ?>
</strong>
<strong>
<?php if($row_roster['zip']<>''){echo $row_roster['zip'];} ?>
</strong><br>
</p>
</td>
</tr>
<tr bgcolor="#FFFFFF" class="style5">
<td><div align="center"><strong>Qty</strong></div></td>
<td><strong>Item</strong></td>
<td><strong>PO?</strong></td>
<td><div align="center"><strong>Paid?</strong></div></td>
<td><div align="center"><strong>Mens/Womens</strong></div></td>
<td><div align="center"><strong>Style</strong></div></td>
<td><div align="center"><strong>Cut</strong></div></td>
<td><div align="center"><strong>Size</strong></div></td>
<td><div align="center"><strong>Price</strong></div></td>
</tr>
<tr bgcolor="#FFFFFF" class="style5">
<td colspan="8"><div align="right">Narc Membership </div></td>
<td><div align="center">
<?php if($row_roster['paid']=="Y"){echo "Paid";$total=0;}else{echo "$".$row_dues['dues'];$total=$row_dues['dues'];} ?></div></td>
</tr>
<?php
do {
$colname_item = "1";
if (isset($row_confirmed['item'])) {
$colname_item = (get_magic_quotes_gpc()) ? $row_confirmed['item'] : addslashes($row_confirmed['item']);
}
mysql_select_db($database_connection1, $connection1);
$query_item = sprintf("SELECT key1, item, price, free FROM clothing WHERE key1 = %s", $colname_item);
$item = mysql_query($query_item, $connection1) or die(mysql_error());
$row_item = mysql_fetch_assoc($item);
$totalRows_item = mysql_num_rows($item);
?>
<tr class="style5">
<td><div align="center"><?php echo $row_confirmed['qty']; ?></div></td>
<td><?php echo $row_item['item']; ?></td>
<td><div align="center"><span class="style45">
<?php if($row_confirmed['postorder']=='Y'){?>YES<?php }?></span></div></td>
<td><div align="center"><?php echo $row_confirmed['paid']; ?></div></td>
<td><div align="center"><?php echo $row_confirmed['mf']; ?></div></td>
<td><div align="center"><?php echo $row_confirmed['style']; ?></div></td>
<td><div align="center"><?php echo $row_confirmed['cut']; ?></div></td>
<td><div align="center"><?php echo $row_confirmed['size']; ?></div></td>
<td><div align="center">
<?php if($row_confirmed['price'] == 0){echo "Free";
}else{
if($row_confirmed['paid']=="Y"){echo "Paid";}else{echo $row_confirmed['price'];$total = $total + $row_confirmed['price'];}
} ?>
</div></td>
</tr>
<?php
} while ($row_confirmed = mysql_fetch_assoc($confirmed)); ?>
<tr bgcolor="#FFFFFF" class="style5">
<td colspan="8"><div align="right"><em><strong>Total Owed</strong></em></div></td>
<td><div align="center" class="style6"><em><strong><?php echo "$".$total.".00";?></strong></em></div></td>
</tr>
</table>
</td>
</tr>
</table>
<div class="page-break"></div>
<?php
}
}while($row_roster = mysql_fetch_assoc($roster));
?>
</body>
我無法測試它,但嘗試將您的表格標籤寫爲'
願意幫忙,但我的眼睛流血從意大利麪代碼:( – arma
回答
我也是在尋找@media打印分頁符{}是「超越酥」!事實上,到目前爲止,發現@media print完全是片狀的。浮動效果不佳,並且幾個樣式細節似乎並沒有像預想的那樣顯示。看起來瀏覽器對「打印」的支持並不理想。我正在開發一個應用程序,該應用程序應該打印名稱徽章,精度對於放置和大小是至關重要的。儘管我希望讓它在網上看起來精明,但是按照我的設想進行打印,但我接近放棄@media print {}樣式。可能必須解決它看起來像徽章。我使用的代碼是每6個「記錄」添加一個分頁符class div(徽章是2,3列中的6列,4「x 3」w)。
如果像我一樣,您無法找到使用@media print {}的方法,它是否可以在屏幕上顯示您希望打印的收據?也可能是你的解決方法,直到(和如果)瀏覽器趕上W3C的慣例。我很想找到一份好的刊物來解釋@media打印樣式是否工作,否則屏幕樣式應該起作用。
來源
2014-03-29 23:22:35
相關問題