Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/267.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/2/jquery/80.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_Jquery_Html - Fatal编程技术网

Php 如何更改输入类型=';文件';动态表中特定行的名称

Php 如何更改输入类型=';文件';动态表中特定行的名称,php,jquery,html,Php,Jquery,Html,我正在对动态表进行编码,其中我选择了3个单独的文件进行上传,文件名显示在相应行的表格单元格中 但是,我只能为第一行选择文件。每次尝试时,我都在努力找出如何为其他行执行此操作,文件名仅显示在第一行中 表输出: 我的代码: <table style="font-size: 15px;" id="table2" border="0"> <thead> <tr> <th width="4%">Ref ID</th&g

我正在对动态表进行编码,其中我选择了3个单独的文件进行上传,文件名显示在相应行的表格单元格中

但是,我只能为第一行选择文件。每次尝试时,我都在努力找出如何为其他行执行此操作,文件名仅显示在第一行中

表输出:

我的代码:

<table style="font-size: 15px;" id="table2" border="0">
    <thead>
    <tr>
        <th width="4%">Ref ID</th>
        <th width="8%">Customer</th>
        <th width="5%">Service</th>
        <th width="10%">Process Map</th>
        <th width="10%">Presentation</th>
        <th width="10%">Requirements</th>
        <th width="7%">Date</th>
        <th width="15%">Action</th>
    </tr>
    <tbody id="doctbody">
    $result_count = mysqli_query( $conn,

    "SELECT COUNT(*) As total_records FROM `customer` `service_type` " );
    $total_records = mysqli_fetch_array( $result_count );
    $total_records = $total_records[ 'total_records' ];
    $total_no_of_pages = ceil( $total_records / $total_records_per_page );
    $second_last = $total_no_of_pages - 1; // total page minus 1

    $result = mysqli_query( $conn, "SELECT customer.Cus_id, customer.Date, customer.customer, service_type.Serv_Name
    FROM customer INNER JOIN service_type ON customer.Cus_id=service_type.Cus_id LIMIT $offset, $total_records_per_page
    " );

    while ( $row = mysqli_fetch_array( $result ) ) {

    echo "
    <tr>
        <td id='input'>" . $row[ 'Cus_id' ] . "</td>
        <td>" . $row[ 'customer' ] . "</td>
        <td>" . $row[ 'Serv_Name' ] . "</td>

        <td id='info' align='left'>
            <div class='image-upload'>
                <label for='file-input'>
                    <img id='img' src='images/noun_Add Document_13006.png' width='20' height='20'/>
                </label>
                <input type='file' id='file-input' name='sortfile'>
                <label id='file-name'>No file</label>
            </div>
        </td>
        <td align='left'>
            <div class='image-upload'>
                <label for='file-input1'>
                    <img src='images/noun_Add Document_13006.png' width='20' height='20'/>
                </label>
                <input type='file' id='file-input1' name='sortfile'>
                <label id='file-name1'>No file</label>
            </div>
        </td>
        <td align='left'>
            <div class='image-upload'>
                <label for='file-input2'>
                    <img src='images/noun_Add Document_13006.png' width='20' height='20'/>
                </label>
                <input type='file' id='file-input2' name='sortfile'>
                <label id='file-name2'>No file</label>
            </div>
        </td>
        <td>" . $row[ 'Date' ] . "</td>
        <td>
            <input type='submit' value='submit' class='btn btn-success' id='UpSubmit' name='UpSubmit'>
            <input type='submit' value='edit' class='btn btn-secondary' name='EdSubmit'>
            <input type='submit' class='btn btn-primary' value='delete' name='deSubmit'>
        </td>
    </tr>
    ";
    }
    mysqli_close( $conn );
    ?>
    </tbody>
</table>

因此,您有一个由3x3个文件输入组成的网格

在水平方向上,它们有ids文件输入、file-input1、file-input2

没关系。

但是在垂直方向上,他们有ID文件输入,文件输入,文件输入

所以你有3倍的相同id。这就是问题所在


的效果是
$(“#file-input1”)
必须决定这些字段的含义,
$(“#file-input1”)
决定只取第一个组件。

可以设置每一行的唯一id吗。。。。。。
$("#file-input").change(function () {
    $("#file-name").text(this.files[0].name);
});

$("#file-input1").change(function () {
    $("#file-name1").text(this.files[0].name);
});
$("#file-input2").change(function () {
    $("#file-name2").text(this.files[0].name);
});