2016-09-27 35 views
-2

我想追加或插入一個html輸入到表的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. 

回答

0

嘗試可能是你的問題

$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>'; 
} 
+0

哇驚人的感謝! –

+0

我可以將css或屬性添加到輸入嗎? –