Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/240.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在php中将滚动条添加到表中?_Php_Html_Css_Mysql - Fatal编程技术网

如何在php中将滚动条添加到表中?

如何在php中将滚动条添加到表中?,php,html,css,mysql,Php,Html,Css,Mysql,我想知道如何将一个滚动条添加到php文件中编写的表中。我不想把它写在style.css文件中,我希望它直接写在php文件中。下面是我的代码,但我无法使它工作。该表从mySql数据库获取内容,该数据库工作正常。但问题是,我得到了很多内容,所以它填满了整个页面。这就是为什么我想让它可以滚动: if(mysqli_num_rows($result) > 0){ echo '<table border="1">'; echo "<tr>

我想知道如何将一个滚动条添加到php文件中编写的表中。我不想把它写在style.css文件中,我希望它直接写在php文件中。下面是我的代码,但我无法使它工作。该表从mySql数据库获取内容,该数据库工作正常。但问题是,我得到了很多内容,所以它填满了整个页面。这就是为什么我想让它可以滚动:

if(mysqli_num_rows($result) > 0){ 
   echo '<table border="1">';
               echo "<tr>";
                   echo "<th>Name</th>";
               echo "</tr>";
   while($row = mysqli_fetch_array($result)){
    echo "<tr>";
         echo "<td>" . $row['name'] . "</td>";
    echo "</tr>";
           }
           echo "</table>";
if(mysqli_num_rows($result)>0){
回声';
回声“;
呼应“姓名”;
回声“;
while($row=mysqli\u fetch\u数组($result)){
回声“;
回显“$row['name']”;
回声“;
}
回声“;

如果我答对了你的问题,你需要设置一个宽度和高度,然后设置overflow-y。这将为你提供一个带有滚动条的特定大小的表格。注意,你需要设置自己的宽度和高度

echo "<table style=\"width:500px; height:500px; overflow-y:auto\">"; 
echo”“;

如果页面超过浏览器窗口大小,浏览器将自动添加滚动条。到底是什么问题?您是否有阻止自动行为的CSS?您是否尝试做其他事情?此外,PHP与您的客户端样式无关。这完全是HTML和CSS。您是否希望它e或否。您只能使用css添加滚动。您可以为添加内嵌样式that@David页面超出了浏览器,但没有添加滚动条。我现在有任何cssall@Sikandar_ali我确实尝试过添加echo“”;但它不起作用。这与PHP或MySQL无关,完全与HTML和CSS有关。