【问题标题】:how to display the data from DB in textarea如何在textarea中显示数据库中的数据
【发布时间】:2014-11-12 06:40:48
【问题描述】:

在下面的代码中,我可以在文本框中显示数据库中的值,但是如何在文本区域中显示它们?

<form action="" method="post">
  <input type="hidden" name="id" value="<?php echo $id; ?>"/>
  <div>
     <p>
     <strong>ID:</strong>    
     <?php echo $id; ?>
     </p>
     <strong>userid: </strong>    
     <input type="text" name="userid" value="<?php echo $userid; ?>" /><br/>
     <strong>name: </strong>     
     <input type="text" name="name" value="<?php echo $name; ?>" /><br/>
     <strong>phoneno: </strong>      
     <input type="text" name="phoneno" value="<?php echo $phoneno; ?>" /><br/>
     <strong>emailid: </strong> 
     <input type="text" name="emailid" value="<?php echo $emailid; ?>" /><br/>
     <strong>description: </strong>    
     <textarea name="description" value="<?php echo $description; ?>" rows="5" cols="40">    </textarea>
</form> 

【问题讨论】:

  • 你能用小提琴找出添加完整代码或添加完整代码的问题
  • 如果您是新开发人员,请在此处提问之前阅读文档。w3schools.com/tags/tag_textarea.asp

标签: php forms get textarea


【解决方案1】:

只要把它放在这样的标签中:

<textarea name="description" rows="5" cols="40"><?= $description; ?></textarea>

【讨论】:

    【解决方案2】:

    不是文本区的值用这个

    <textarea name="description" rows="5" cols="40"><?php echo $description; ?></textarea>
    

    【讨论】:

      【解决方案3】:

      改变这个

      <textarea name="description" value="<?php echo $description; ?>" rows="5" cols="40"></textarea>
      

      <textarea name="description"  rows="5" cols="40"><?php echo $description; ?></textarea>
      

      【讨论】:

        【解决方案4】:
        <textarea name="description"><?php echo $description; ?></textarea>
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2018-04-10
          • 1970-01-01
          • 2015-12-18
          • 1970-01-01
          • 1970-01-01
          • 2015-12-04
          • 2016-12-19
          • 1970-01-01
          相关资源
          最近更新 更多