-1

我正在尝试创建一个从数据库调用值的表。问题是数据是水平压缩的。我想添加一个水平滚动条,这样输出就不会在另一个单词上垂直狭窄。

这是我的代码

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>');
4

4 回答 4

0

使用溢出-x(如何使用溢出)标签:

overflow-x: scroll
于 2013-05-07T06:54:55.710 回答
0

首先不要使用 PHP 回显 HTML,如果它太多的话,这样做

<!--HTML Here-->

<?php
   //PHP Here
?>

<!--HTML Here Again-->

遇到你的问题,有一个像 div 这样具有固定宽度和 use 的容器元素overflow: scroll;,并使用width: 100%;orwidth: 1000px; /* Fixed Width */为你的table

与您的评论相关的更新

<?php
   if(condition) {
?>
<!-- HTML Here -->
<?php
   }
?>
于 2013-05-07T06:55:43.757 回答
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>";
于 2013-05-07T06:57:36.627 回答
0

您可以使用 CSS 属性 overflow:auto 或 overflow:scroll 轻松完成您正在使用的表格

于 2013-05-07T07:00:50.417 回答