如何从后端向返回的表插入html输入


How to insert html input to the returned table from the backend?

我想在表的td中添加或插入一个html输入。你知道怎么做吗?

这是我的html表单index.php:

<table class="stack">
    <thead class="tblthead">
       <tr>
          <th>Filename</th>
          <th width="400">Date/Time</th>
          <th width="300">Action</th>
       </tr>
    </thead>
    <tbody id="importable">
    </tbody>
</table>

这是我的backend.php,这是我返回数据到frontend的地方,也就是我的index.php

case 'filerec':
                $arr =[
                        ":userID" => $_SESSION['loggedIn_PH'][0]['user_id'],
                    ];
                    $query = "SELECT * FROM file_rec_tbl WHERE user_id=:userID ORDER BY file_id DESC";

                    $stmt = $con -> prepare( $query );
                    $stmt -> execute( $arr );
                    $data = $stmt -> fetchAll();

                    $table = '';
                    for( $x = 0; $x < count($data); $x++ ) {
                        $table .= '<tr fileID="'.$data[$x]['file_id'].'">
                                <td>'.$data[$x]['file_name'].'</td>
                                <td>'.$data[$x]['file_datetime'].'</td>
                                <td>'.html('<input type="text"></input>')
                            </tr>';
                    }
                    exit ($table);
                break;
I got an error to the last td. Can you please help me or suggest what might be a good solution to my problem.

可能是你的问题

$table = '';
for( $x = 0; $x < count($data); $x++ ) {
   $table .= '<tr fileID="'.$data[$x]["file_id"].'">
              <td>'.$data[$x]["file_name"].'</td>
              <td>'.$data[$x]["file_datetime"].'</td>
              <td><input type="text"></input></td>
   </tr>';
}