2011-10-20 82 views
0


我想制作一个网站,从csv文件读取并以可打印格式(用于打印票据)在屏幕上呈现数据。该页面每行创建2张票据并循环投掷,直到数据用完。这一切都很完美,看起来只是我想要的方式,但是,当我打印它时,第三行向下移动了其中一行文本,并移动到它上面的行中。

我的问题是,如何让它在屏幕上看到它的打印方式,以及为什么当所有的行都用相同的代码制作时,它只会搞砸第三行。

感谢 编辑:正确打印网站

while (!feof($file_handle)){` 
$csvText = fgetcsv($file_handle, 1024); 
    $username = $csvText[1]; 
    $password = $csvText[2]; 
    $profile = $csvText[3]; 
    $daysValid = $csvText[4]; 
    $expiry = $csvText[5]; 

if($pos == 0) 
{ 
if($count == 5){ 
echo "<p><br /></p>"; 

$count = 0; 
}else{ 
$count++; 
} 
echo "<div class='itemRow'>"; 
echo "<div class='left'>"; 
$pos = 1; 
?> 
<h4 class="centre">Internet Access Voucher</h4> 
<img class="image" src="./icon.jpg" /> 
<div class="info"> 
<table> 
    <tr> 
     <td> 
      Username 
     </td> 
    </tr> 
    <tr> 
     <td> 
      Password 
     </td> 
    </tr> 
    <tr> 
     <td> 
      Profile 
     </td> 
    </tr> 
    <tr> 
     <td> 
      Valid for 
     </td> 
    </tr> 
    <tr> 
     <td> 
      Expiry date 
     </td> 
    </tr> 
</table> 
</div> 
<div class="uniqueInfo"> 
<table> 
    <tr> 
     <td> 
      <?php echo $username;?> 
     </td> 
    </tr> 
    <tr> 
     <td> 
      <?php echo $password;?> 
     </td> 
    </tr> 
    <tr> 
     <td> 
      <?php echo $profile;?> 
     </td> 
    </tr> 
    <tr> 
     <td> 
      <?php echo $daysValid;?> 
     </td> 
    </tr> 
    <tr> 
     <td> 
      <?php echo $expiry;?> 
     </td> 
    </tr> 
</table> 
</div> 
<p class="centre"><br />Please remember to disconnect to stop each session.</p> 
</div> 
<br /> 

<?php 
} else { 
?> 
<div class="right"> 
<h4 class="centre">Internet Access Voucher</h4> 
<img class="imageRight" src="./icon.jpg" /> 
<div class="infoRight"> 
<table> 
    <tr> 
     <td> 
      Username 
     </td> 
    </tr> 
    <tr> 
     <td> 
      Password 
     </td> 
    </tr> 
    <tr> 
     <td> 
      Profile 
     </td> 
    </tr> 
    <tr> 
     <td> 
      Valid for 
     </td> 
    </tr> 
    <tr> 
     <td> 
      Expiry date 
     </td> 
    </tr> 
</table> 
</div> 
<div class="uniqueInfoRight"> 
<table> 
    <tr> 
     <td> 
      <?php echo $username;?> 
     </td> 
    </tr> 
    <tr> 
     <td> 
      <?php echo $password;?> 
     </td> 
    </tr> 
    <tr> 
     <td> 
      <?php echo $profile;?> 
     </td> 
    </tr> 
    <tr> 
     <td> 
      <?php echo $daysValid;?> 
     </td> 
    </tr> 
    <tr> 
     <td> 
      <?php echo $expiry;?> 
     </td> 
    </tr> 
</table> 
</div> 
<p class="centre"><br />Please remember to disconnect to stop each session.</p> 
</div> 

</div> 

<?php 
$pos = 0; 
} 
} 
?> 

CSS

.centre 
{ 
text-align:center; 
} 

.itemRow 
{ 
position:relative; 
top:0px; 
} 

.left 
{ 
width:500px; 
position:relative; 
font-family:Comic Sans, Comic sans MS, cursive; 
/*border-style:solid; 
border-width:1px;*/ 
} 

.right 
{ 
width:500px; 
position:absolute; 
left:600px; 
top:-20px; 
font-family:Comic Sans, Comic sans MS, cursive; 
/*(border-style:solid; 
border-width:1px;*/ 
} 

.image 
{ 
position:absolute; 
top:70px; 
} 

.info 
{ 
position:relative; 
left:63px; 
} 

.uniqueInfo 
{ 
position:absolute; 
left:250px; 
top:42px; 
} 

.infoRight 
{ 
position:relative; 
left:63px; 
top:0px; 
} 

.uniqueInfoRight 
{ 
position:absolute; 
left:250px; 
top:65px; 
} 

.imageRight 
{ 
position:absolute; 
top:90px; 
} 
+0

没有看到您的代码,我们无法帮助您。 – Anson

+0

创建一个用于打印的css文件。 – NVTOnline

+0

但特别是会有所帮助,搞砸了的文字是在一个表中,所以我没有看到它可以如何移动到另一行 – Darc

回答

0

我怀疑这可能是问题:

if($count == 5){ 
    echo "<p><br /></p>"; 

你有2个,每行和每票后增加$count 。因此,$count = 5将在第四张票后,或第三行开始。样本HTML页面会给我什么也正是事情的一个更好的主意,但我会建议做这样

<br style="clear: both;" /> 
行之间

,这对他们干净分裂。所以票3和5之前($count = 3$count = 5)。