我正在尝试创建一个从数据库中调用值的表。问题是数据是水平压缩的。我想添加一个水平滚动条,这样输出就不会在另一个字上垂直缩小。
这是我的代码
echo('<table border="1">');
echo "<tr>
<td5Folder</td>
<td>MDU</td>
<td>Contractor</td>
<td>Team</td>
<td>RDate</td>
<td>SIDate</td>
<td>ICDate</td>
<td>Status</td>
<td>Remarks1</td>
<td>Remarks2</td>
<td>Remarks3</td>
<td>Bill50</td>
<td>Bill30</td>
<td>Bill20</td>
<td>BillRemark</td>
</tr>";
while($row = mysql_fetch_array($rs)) {
$folderx = $row['FolderNo'];
$mdux = $row['MDU'];
$contractorx = $row['Contractor'];
$teamx = $row['Team'];
$rdatex = $row['RDate'];
$sidatex = $row['SIDate'];
$icdatex = $row['ICDate'];
$statusx = $row['Status'];
$remarks1x = $row['Remarks1'];
$remarks2x = $row['Remarks2'];
$remarks3x = $row['Remarks3'];
$bill50x = $row['Bill50'];
$bill30x = $row['Bill30'];
$bill20x = $row['Bill20'];
$billRemarkx = $row['BillRemark'];
echo "<tr>
<td>$folderx</td>
<td>$mdux</td>
<td>$contractorx</td>
<td>$teamx</td>
<td>$rdatex</td>
<td>$sidatex</td>
<td>$icdatex</td>
<td>$statusx</td>
<td>$remarks1x</td>
<td>$remarks2x</td>
<td>$remarks3x</td>
<td>$bill50x</td>
<td>$bill30x</td>
<td>$bill20x</td>
<td>$billRemarkx</td>
</tr>";
}
echo('</table>');
答案 0 :(得分:0)
使用overflow-x(How to use overflow)标记:
overflow-x: scroll
答案 1 :(得分:0)
首先不要使用PHP回显HTML,如果它太多了,就像这样做
<!--HTML Here-->
<?php
//PHP Here
?>
<!--HTML Here Again-->
为了解决您的问题,请使用带有固定宽度的div等容器元素并使用overflow: scroll;
,并使用width: 100%;
或width: 1000px; /* Fixed Width */
作为table
与您的评论相关的更新
<?php
if(condition) {
?>
<!-- HTML Here -->
<?php
}
?>
答案 2 :(得分:0)
试试这个!
echo "<div style='overflow-x:auto;'>";
echo('<table border="1">');
echo "<tr>
<td>Folder</td>
<td>MDU</td>
<td>Contractor</td>
<td>Team</td>
<td>RDate</td>
<td>SIDate</td>
<td>ICDate</td>
<td>Status</td>
<td>Remarks1</td>
<td>Remarks2</td>
<td>Remarks3</td>
<td>Bill50</td>
<td>Bill30</td>
<td>Bill20</td>
<td>BillRemark</td>
</tr>";
while($row = mysql_fetch_array($rs)) {
$folderx = $row['FolderNo'];
$mdux = $row['MDU'];
$contractorx = $row['Contractor'];
$teamx = $row['Team'];
$rdatex = $row['RDate'];
$sidatex = $row['SIDate'];
$icdatex = $row['ICDate'];
$statusx = $row['Status'];
$remarks1x = $row['Remarks1'];
$remarks2x = $row['Remarks2'];
$remarks3x = $row['Remarks3'];
$bill50x = $row['Bill50'];
$bill30x = $row['Bill30'];
$bill20x = $row['Bill20'];
$billRemarkx = $row['BillRemark'];
echo "<tr>
<td>$folderx</td>
<td>$mdux</td>
<td>$contractorx</td>
<td>$teamx</td>
<td>$rdatex</td>
<td>$sidatex</td>
<td>$icdatex</td>
<td>$statusx</td>
<td>$remarks1x</td>
<td>$remarks2x</td>
<td>$remarks3x</td>
<td>$bill50x</td>
<td>$bill30x</td>
<td>$bill20x</td>
<td>$billRemarkx</td>
</tr>";
}
echo('</table>');
echo "</div>";
答案 3 :(得分:0)
您可以使用CSS属性overflow:auto或overflow:滚动显示正在使用的表