dongshun7312
2016-10-07 17:34
浏览 126
已采纳

在textarea中显示数据库值[重复]

This question already has an answer here:

I am trying to display the value of a textarea in a form that will enable someone to edit its value. The textarea displays nothing but I checked the database and there is a 2 sentence value. Here is the code I am using:

<textarea rows="5" cols="55" name="P1Bio" value="<?=$record['P1Bio']?>">
</textarea>

P1Bio is the field. On the same form, I am also getting values from textboxes and it is working fine. Here is the code that I am using for text boxes:

<input type="text" size="90" name="P1Email" value="
<?=$record['P1Email']?>">

Can someone please tell me why the textarea is not showing anything? Thank you.

</div>

图片转代码服务由CSDN问答提供 功能建议

此问题已经存在 这里有一个答案:

  • textarea不能有默认值[复制] 7 answers

    我正在尝试以某种形式显示textarea的值 编辑它的价值。 textarea显示什么,但我检查了数据库,并有一个2句话值。 这是我正在使用的代码:

     &lt; textarea rows =“5”cols =“55”name =“P1Bio”value =“&lt;?= $ record [  'P1Bio']?&gt;“&gt; 
    &lt; / textarea&gt; 
       
     
     

    P1Bio是该字段。 在同一个表单上,我也从文本框中获取值,它工作正常。 以下是我用于文本框的代码:

     &lt; input type =“text”size =“90”name =“P1Email”value =“
    &lt;  ?= $ record ['P1Email']?&gt;“&gt; 
       
     
     

    有人可以告诉我为什么textarea没有显示任何内容吗? 谢谢。

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

4条回答 默认 最新

  • duanbichou4942 2016-10-07 17:35
    已采纳

    There is no value attribute with textareas.

    You need to put the content in between the open and closing tags like this:

    <textarea rows="5" cols="55" name="P1Bio"><?=$record['P1Bio']?></textarea>
    
    已采纳该答案
    打赏 评论
  • dongxin9759 2016-10-07 17:36

    Your php needs to be inside the text area

     <textarea><? Php code? ></textarea>
    
    打赏 评论
  • duan0417 2016-10-07 17:36

    Try

    <textarea rows="5" cols="55" name="P1Bio><?=$record['P1Bio']?></textarea>
    
    打赏 评论
  • duan0818 2016-10-07 17:36

    Unlike texts (like <input type="text">), content in textareas are inside the tags:

    <textarea rows="5" cols="55" name="P1Bio" value=""><?=$record['P1Bio']?></textarea>
    

    Some information regarding this: HTML Tag

    打赏 评论

相关推荐 更多相似问题