使用输入标记html显示从表到编辑的数据

时间:2018-01-17 04:54:53

标签: javascript php html css

目前我仍在尝试使用html和php代码。我创建了一个页面,显示从数据库到表格的所有内容,可以为每行编辑。单击编辑按钮后,将转到下一页编辑数据。 基本上要进行编辑,内容应该显示在编辑页面上。某些内容可能很长,所以我想使用<textarea>来获取它们,因为如果我使用<input>标记,则无法调整高度意味着内容仅显示在一行中。但是当我使用<textarea>标签时,它根本不会显示任何内容。它没有获取数据。所以我想知道我是否错过了什么?我需要从多个行中获取/显示表中的内容。以下是我的编辑页面中代码的一部分。

&#13;
&#13;
 <form method="post">
     <table>
         <tr>
             <td>No Seq</td>
             <td><input type="text" name="id" value="<?php echo $id;?>"></td>
         </tr>
         <tr>
             <td>Department</td>
             <td> <select  name="department" style="width: 452px;" value="<?php echo $department; ?>">
                  <option value="IT">it</option>
                  <option value="purchasing">purchasing</option>
                  <option value="finance">finance</option>
             </td>
         </tr>
         <tr>
             <td>Person in Charge</td>
             <td> </td>
         </tr>
         <tr>
             <td>Project Title</td>
             <td> <input type="text" name="project_title" size="60" value="<?php echo $project_title;?>"> </td>
         </tr>
         <tr>
             <td>Objective</td>
             <td> <textarea type="text" name="objective" style="height: 50px; width: 445px;" value="<?php echo $objective;?>"> </textarea> </td>
         </tr>
         <tr>
             <td>How To Do</td>
             <td> <textarea type="text" name="how_to_do" size="60" style="height: 110px; width: 445px;" value="<?php echo $how_to_do;?>"> </textarea></td>
         </tr>
         <tr>
             <td>Activities</td>
             <td> <textarea type="text" name="activities" size="60" style="height: 110px; width: 445px;" value="<?php echo $activities;?>"> </textarea></td>
         </tr>
         <tr>
             <td>Project Started</td>
             <td> <input type="date" name="prostart" size="60" style="width: 445px;" value="<?php echo $project_started;?>"></td>
         </tr>
         <tr>
             <td>Project Completed</td>
             <td> <input type="date" name="procomplete" size="60" style="width: 445px;" value="<?php echo $project_completed;?>"></td>
         </tr>
         <tr>
             <td>Target Cost Saving</td>
             <td><input type="text" name="targetcost" size="60" value="<?php echo $target_cost_saving;?>"></td>
         </tr>
         <tr>
             <td>Cost Saving After Justification</td>
             <td><input type="text" name="costafter" size="60" value="<?php echo $costsaving_afterjustification;?>"></td>
         </tr>
         <tr>
             <td>Cost Saving Monthly After Justification</td>
             <td><input type="text" name="costmonthly" size="60" value="<?php echo $costsaving_monthly?>"></td>
         </tr>
     </table>
     <br> <br>
     <input style="width: 80px; height: 30px; margin-left: 750px;" type="submit" name="update" value="Cancel" acti>
     <input style="width: 80px; height: 30px;" type="submit" name="update">
 </form> <br>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:1)

TEXTAREA不接受参数 value = ,要为TEXTAREA设置默认内容,需要在标签之间插入数据,如下例所示:

<textarea type="text" name="objective" style="height: 50px; width: 445px;"><?php echo $objective;?></textarea>

另请参阅:https://www.w3schools.com/tags/tag_textarea.asp

相关问题