Php 在子目录中创建特定文件的列表

Php 在子目录中创建特定文件的列表,php,html,directory-listing,file-listing,Php,Html,Directory Listing,File Listing,我有一个结构: [目录] [目录-name-1] [资料] name-1.html-来自其他表单的已发布值表 name-2.html-来自其他表单的已发布值表 name-3.html-来自其他表单的已发布值表 name-n.html-来自其他表单的已发布值表 catalog-name-1.html [目录名称-2] catalog-name-2.html [目录名称-3] catalog-name-3.html index.php 如何在catalog name-?.htm

我有一个结构:

  • [目录]
  • [目录-name-1]
    • [资料]
      • name-1.html-来自其他表单的已发布值表
      • name-2.html-来自其他表单的已发布值表
      • name-3.html-来自其他表单的已发布值表
      • name-n.html-来自其他表单的已发布值表
    • catalog-name-1.html
    • [目录名称-2]
      • catalog-name-2.html
    • [目录名称-3]
      • catalog-name-3.html
index.php

  • 如何在catalog name-?.html中编写函数,以便将所有数据表的内容合并到catalog name-?.html中的一个html表中

  • 如何编写index.php以将所有目录名-?.html文件列为链接列表


  • 谢谢你的提示。涉及3个PHP文件: index.php-有一个条目表单将值发布到work/data.php文件中,然后在其中操作的值将保存在各自的data\u HTML文件夹中的新HTML文件中,然后由work/preview.php显示。在data.php中,有以下代码:

    <?php
    // directory names 
    $dir_catalogues = '../catalogues/';
    $dir_catalogue = $dir_catalogues.$_POST['catalogue_name'];
    $dir_html = $dir_catalogue.'/data_html/'; 
    $dir_csv = $dir_catalogue.'/data_csv/';
    
    //Check if the directory with the name already exists
    //Create our directory if it does not exist
    if (!is_dir($dir_catalogues)) {
    mkdir($dir_catalogues);
    echo "Directory ".$dir_catalogues." created<br>";
    }
    if (!is_dir($dir_catalogue)) {
    mkdir($dir_catalogue);
    echo "Directory ".$dir_catalogue." created<br>";
    }
    if (!is_dir($dir_html)) {
    mkdir($dir_html);
    echo "Directory ".$dir_html." created<br>";
    }
    if (!is_dir($dir_csv)) {
    mkdir($dir_csv);
    echo "Directory ".$dir_csv." created";
    }
    
    // file names 
    $img_name_html = $_POST['img_name'].'.html';
    $img_name_csv = $_POST['img_name'].'.csv';
    $catalogue_name = 'catalogue-'.$_POST['catalogue_name'].'.html';
    
    // HTML file content 
    $html = '
    <!DOCTYPE html>
    <html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Images rights information</title>
        <style>
            ...
        </style>
    </head>
    <body>
    <div class="wrapper">
    <table cellpadding="5">
    <th colspan="2">Image info</th>
    <tr class="thumb_row""><td class="logo" colspan="2"><img class="img_thumb" src="'.$_POST['img_use_url'].'" alt="Thumbnail"><h3>'.$_POST['img_title'].'</h3></td></tr>
    <tr><td width="140" class="lab">File name</td><td colspan="5">'.$_POST['img_name'].'</td></tr>
    <tr><td width="140" class="lab">Description</td><td colspan="5">'.$_POST['img_description'].'</td></tr>
    <tr><td width="140" class="lab">Source URL</td><td colspan="5"><a href="'.$_POST['img_source_url'].'" target="_blank">'.$_POST['img_source_url'].'</a></td></tr>
    <tr><td width="140" class="lab">Image use URL</td><td colspan="5"><a href="'.$_POST['img_use_url'].'" target="_blank">'.$_POST['img_use_url'].'</a></td></tr>
    <tr><td width="140" class="lab">Copyright owner</td><td colspan="5">'.$_POST['img_copyright_owner'].'</td></tr>
    <tr><td width="140" class="lab">Author</td><td colspan="5">'.$_POST['img_author'].'</td></tr>
    <tr><td width="140" class="lab">Author\'s URL</td><td colspan="5"><a href="'.$_POST['img_author_url'].'" target="_blank">'.$_POST['img_author_url'].'</a></td></tr>
    <tr><td width="140" class="lab">License</td><td colspan="5">'.$_POST['img_license'].'</td></tr>
    <tr><td width="140" class="lab">License Nr.</td><td colspan="5">'.$_POST['img_license_nr'].'</td></tr>
    </table>
    </div>
    </body>
    </html>';
    ......
    // create catalogue HTML file
        file_put_contents($dir_catalogue .'/'.$catalogue_name, $html, FILE_APPEND | LOCK_EX);
    

    我取得了一些进展(发现并应用了som工作脚本)。但我坚持以下几点:
    到目前为止,我的代码中已经包含了以下内容:

    
    图像版权信息
    *{字体系列:arial、tahoma、verdana;}
    .wrapper{宽度:900px;边距:自动;框大小:边框框;}
    表{宽度:100%}
    th{字体大小:2.2em;字体重量:粗体;}
    .thumb_row{背景:#eee;}
    td.logo,th{边框底部:2px实心#999;}
    .img_thumb{max_height:180px;width:auto;margin:2em;float:left;}
    td.logo img{float:左;margin right:2em;}
    td a img{边框:2px纯蓝色;}
    td a:悬停img{边框:2px实心橙色;}
    td.lab{font-weight:bold;垂直对齐:top;}
    td h3{字体大小:2em;字体重量:粗体}
    图像信息
    “.$”帖子['img_title'.]
    文件名“$\u POST['img\u name']”
    说明。$\u帖子['img\u说明'].'
    源URL
    图像使用URL
    版权所有人。$\u POST['img\u版权所有人'.]
    作者。$\u POST['img\u Author'.]
    作者的URL
    许可证。$\u POST['img\u许可证'].'
    许可证编号:$邮政['img\U许可证编号].'
    //CSV文件内容
    本次发布的文章(img的名字是你们的名字,你们们的名字是你们们的名字是你们们的名字是你们们的名字是你们们的名字是你们们的名字是你们们的名字是你们们的名字是你们们发布的文章(img的名字是你们们的名字是你们们的名字是你们们的名字是你们们的名字是你们们的名字是你们们的名字是你们们的名字是你们们的名字是你们们的名字是你们们的名字是你们们的名字是你们们的名字是你们们的名字是你们们的名字的名字是你们们的名字是你们们的名字是你们们的名字的名字是你们们的名字的名字是你们们的名字是你们们的名字是你们们的名字是你们们的名字的名字是你们们的名字的名字是你们们的名字是你们们的名字是你们们的名字是你们们的名字是你们们的名字是你们们的名字是你们们的名字是你们们的名字是你们们的名字是你们们的名字的[许可证编号];
    //创建目录HTML文件
    文件内容($dir_catalog./'.$catalog_name.'.html',$html,文件附加| LOCK_EX);
    文件内容($dir\u catalog.'/index.html',$html,文件附加| LOCK\u EX);
    //创建目录CSV文件
    文件内容($dir_catalog./'.$catalog_name.'.csv',$csv,文件附加| LOCK_EX);
    文件内容($dir_catalog.'/index.csv',$csv,文件附加| LOCK_EX);
    
    }
    试试
    /cataloges/cataloges-name-1/cataloge-name-1.html
    等等(如果文件夹
    cataloge
    位于文档根目录中),为什么要还原使问题更具可读性的编辑?问题的可读性越强,你得到答案的可能性就越大。如果你发布了你已经拥有的代码,解释什么是有效的/无效的以及你被困在哪里,这也会有所帮助。我们总是很乐意帮助和支持新的程序员,但我们希望您首先尝试自己编写代码。可能有助于获取文件谢谢你的提示。涉及3个PHP文件: