嗨我正在查看我要删除的文件夹中的文件,现在工作正常,但图像在一个列表中,我想在5列中显示图像,我尝试添加表但不能得到它工作,任何想法?这是我的代码
<form id="stallionidelete" method="post" enctype="multipart/form-data">
<?php
$dir = dirname(__FILENAME__)."/images/gallery" ;
$files1 = scandir($dir);
foreach($files1 as $file) {
if(strlen($file) >=3) {
$foil = strstr($file, 'jpg'); // As of PHP 5.3.0
$foil = $file;
$pos = strpos($file, 'css');
if ($foil==true) {
$i == ++$i;
echo '<table><tr>';
echo '<div class="gimage_'.$i.'"><input type="checkbox" id="gimage_'.$i.'" name="filenames['.$i.'][]" value="'.$foil.'" />';
echo "<img width='150' height='150' src='images/gallery/$file' /><br/></div>";
echo '</tr></table>';
// for live host
//echo "<img width='130' height='38' src='/ABOOK/SORTING/gallery-dynamic/images/gallery/$file' /><br/>";
}
}
}
?>
<input type="submit" name="mysubmit2" value="Delete">
</form>
答案 0 :(得分:0)
这就是你应该如何做代码
<form id="stallionidelete" method="post" enctype="multipart/form-data">
<table border='1' width='546' cellspacing='0' cellpadding='0' bordercolor="#E1F5FF">
<tr>
<td>
<table summary='table' style="width: 797px">
<thead id="start">
<tr>
<th width='150' style="height: 40px">Image1</th>
<th width='150' style="height: 40px">image2</th>
<th width='150' style="height: 40px">Image3</th>
<th width='150' style="height: 40px">image4</th>
<th width='150' style="height: 40px">image5</th>
</tr>
</thead>
<tfoot>
</tfoot>
<tbody>
<tr>
<?php
$dir = dirname(__FILENAME__)."/images/gallery" ;
$files1 = scandir($dir);
foreach($files1 as $file){
if(strlen($file) >=3){
$foil = strstr($file, 'jpg'); // As of PHP 5.3.0
$foil = $file;
$pos = strpos($file, 'css');
if ($foil==true){
$i == ++$i;
echo '<td bgcolor="#F7F7F7" width="183">';
echo '<div class="gimage_'.$i.'"><input type="checkbox" id="gimage_'.$i.'" name="filenames['.$i.'][]" value="'.$foil.'" />';
echo "<img width='150' height='150' src='images/gallery/$file' /><br/></div>";
echo '</td>';
// for live host
//echo "<img width='130' height='38' src='/ABOOK/SORTING/gallery-dynamic/images/gallery/$file' /><br/>";
}
}
}?>
</table>
</tr>
</tbody>
</table></td>
</tr>
</table>
</form>
<input type="submit" name="mysubmit2" value="Delete">
你没有回声表也忘了放<td>tag</td>
我想在这里缩短误解你可以基本检查这个并告诉我这是否是你需要的吗?
答案 1 :(得分:0)
我认为以下内容会有所帮助。
$dir = dirname(__FILENAME__)."/images/gallery" ;
$files1 = scandir($dir);
if ($files1) {
echo '<table>';
$fileCount = 0;
foreach($files1 as $file){
if(strlen($file) >=3 && strstr($file, 'jpg')){
if ($fileCount % 4 == 0) {
if ($fileCount > 0) {
echo '</tr>';
}
echo '<tr>';
}
echo '<td>
<input type="checkbox" id="gimage_'.$i.'" name="filenames['.$i.'][]" value="'.$foil.'" />
<img width="150" height="150" src="images/gallery/'.$file.'" />
</td>';
$fileCount++;
}
}
if ($fileCount > 0){
if ($fileCount % 4 > 0){
echo '<td colspan="'.($fileCount%4).'"></td>';
}
echo '</tr>';
}
echo '</table>';
echo '<input type="submit" name="mysubmit2" value="Delete">';
}