如何制作 table 来组织 PHP 中的按钮
How to make a table to organize buttons in PHP
我有这段代码可以从目录中的文件创建按钮。我需要将它们组织在一个包含 4 列的 table 中。我该怎么做?
这是我的代码:
$handle = opendir('mydirectory');
if($handle){
while(($entry = readdir($handle)) !== false){
if($entry != '.' && $entry != '..' && $entry != '.htaccess'){
echo "<button onclick=\"location.href='mydirectory/$entry'\" style=\"background-color: #660000;\"><p style=color:white;>$entry</button><br>";
}
}
closedir($handle);
根据@Raptor 在评论中提到的内容,您可以这样做:
<style>
#buttons{
width: 300px;
float:left;
}
</style>
<div id="buttons">
<?php
for($i=0;$i <=10; $i++){
echo "<button>Button $i</button>";
}
?>
</div>
我有这段代码可以从目录中的文件创建按钮。我需要将它们组织在一个包含 4 列的 table 中。我该怎么做?
这是我的代码:
$handle = opendir('mydirectory');
if($handle){
while(($entry = readdir($handle)) !== false){
if($entry != '.' && $entry != '..' && $entry != '.htaccess'){
echo "<button onclick=\"location.href='mydirectory/$entry'\" style=\"background-color: #660000;\"><p style=color:white;>$entry</button><br>";
}
}
closedir($handle);
根据@Raptor 在评论中提到的内容,您可以这样做:
<style>
#buttons{
width: 300px;
float:left;
}
</style>
<div id="buttons">
<?php
for($i=0;$i <=10; $i++){
echo "<button>Button $i</button>";
}
?>
</div>