我正在尝试创建一个从csv文件读取的网站,并以可打印的格式在屏幕上呈现数据(用于打印票据)。该页面每行创建2个票证,并且循环丢弃直到数据耗尽。这一切都很完美,看起来就像我想要它的方式但是,当我打印它时,第三行向下有一行文字向上移动到它上面的线上。
我的问题是如何让它以在屏幕上看到的方式打印出来,为什么当所有行都用相同的代码制作时它只会搞砸第3行。
感谢
编辑:
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 :(得分:0)
我怀疑这可能是问题所在:
if($count == 5){
echo "<p><br /></p>";
每行有2个,每张票后增加$count
。因此,$count = 5
将在第四张票之后,或第三行开始时。一个示例HTML页面可以让我更好地了解正在发生的事情,但我建议做一些类似的事情
<br style="clear: both;" />
在行之间干净地拆分它们。因此,在机票3和5之前($count = 3
和$count = 5
)。