gpt4 book ai didi

php - 如何使带有固定标题和来自mysql的表内容的表可滚动

转载 作者:行者123 更新时间:2023-11-28 14:00:39 25 4
gpt4 key购买 nike

如何让这个表格可以滚动?我尝试了不同的代码,但我总是在这一行遇到问题:$avaya=mysql_query("SELECT * From avaya_pabx"); .当我回显 <td> 时,我使用的其他代码出现了问题.

这是我的代码:

<div id="pageContent">

<title>Avaya PABX</title>
<table class='hovertable'>
<tr>
<th width="31">---</th>
<th width="12%">Critical Spare ID</th>
<th width="11%">Serial No.</th>
<th width="8%">Comcode</th>
<th width="9%">Version</th>
<th width="12%">Circuit Pack</th>
<th width="13%">Classification</th>
<th width="8%">Location</th>
<th width="12%">Availability</th>
<th width="5%">Date</th>
<th width="7%">Client</th>
</tr>

<?php

$avaya=mysql_query("SELECT * From avaya_pabx");

$alternate=0;

while ($row=mysql_fetch_array($avaya))
{
$alternate++;
if ($alternate==3)
$alternate=1;
echo "<tr class=class$alternate onmouseover=\"this.style.backgroundColor='#ffff66';\" onmouseout=\"this.style.backgroundColor='#d4e3e5';\">";
echo "<td><font size=1><a href='deleteavaya.php?serial_no=" . $row['serial_no'] . "' onclick=\"return confirmdelete('$row[serial_no]')\">[Delete]</a></font></td>";
echo "<td>" . $row['critical_spare_id'] . "</td>";
echo "<td>" . $row['serial_no'] . "</td>";
echo "<td>" . $row['comcode'] . "</td>";
echo "<td>" . $row['version'] . "</td>";
echo "<td>" . $row['circuit_pack'] . "</td>";
echo "<td>" . $row['classification'] . "</td>";
echo "<td>" . $row['location'] . "</td>";
echo "<td>" . $row['availability'] . "</td>";
echo "<td>" . $row['date'] . "</td>";
echo "<td>" . $row['client'] . "</td>";
}

?>
</table>

<style>
#pageContent
{
width:100%;
height:18cm;
overflow:scroll;
}
</style>

最佳答案

将表格内容回显到 div 内的新表格中,该表格应用了以下 css:

width:auto; /* or what you need it to be */
height: 500px; /* make this the size you want the data to be displayed in */
overflow: auto; /* this adds the scroll bars to the div when any data exceeds its hieght */

关于php - 如何使带有固定标题和来自mysql的表内容的表可滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10378072/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com